@@ -87,7 +87,11 @@ impl Theme {
8787 self . styles [ ALERT_TYPES . get ( & severity) . unwrap ( ) ]
8888 }
8989
90- pub fn new ( name : String , parent : Option < String > , styles : HashMap < Meaning , ContentStyle > ) -> Theme {
90+ pub fn new (
91+ name : String ,
92+ parent : Option < String > ,
93+ styles : HashMap < Meaning , ContentStyle > ,
94+ ) -> Theme {
9195 Theme {
9296 name,
9397 parent,
@@ -136,7 +140,7 @@ impl Theme {
136140 ) ;
137141 }
138142 ContentStyle :: default ( )
139- } )
143+ } ) ,
140144 )
141145 } )
142146 . collect ( ) ;
@@ -145,7 +149,11 @@ impl Theme {
145149
146150 // Boil down a meaning-color hashmap into a theme, by taking the defaults
147151 // for any unknown colors
148- fn from_map ( name : String , parent : Option < & Theme > , overrides : & HashMap < Meaning , ContentStyle > ) -> Theme {
152+ fn from_map (
153+ name : String ,
154+ parent : Option < & Theme > ,
155+ overrides : & HashMap < Meaning , ContentStyle > ,
156+ ) -> Theme {
149157 let styles = match parent {
150158 Some ( theme) => Box :: new ( theme. styles . clone ( ) ) ,
151159 None => Box :: new ( DEFAULT_THEME . styles . clone ( ) ) ,
@@ -198,7 +206,7 @@ impl StyleFactory {
198206 fn from_fg_string ( name : & str ) -> Result < ContentStyle , String > {
199207 match from_string ( name) {
200208 Ok ( color) => Ok ( Self :: from_fg_color ( color) ) ,
201- Err ( err) => Err ( err)
209+ Err ( err) => Err ( err) ,
202210 }
203211 }
204212
@@ -240,14 +248,26 @@ lazy_static! {
240248 None ,
241249 HashMap :: from( [
242250 ( Meaning :: AlertError , StyleFactory :: from_fg_color( Color :: Red ) ) ,
243- ( Meaning :: AlertWarn , StyleFactory :: from_fg_color( Color :: Yellow ) ) ,
244- ( Meaning :: AlertInfo , StyleFactory :: from_fg_color( Color :: Green ) ) ,
245- ( Meaning :: Annotation , StyleFactory :: from_fg_color( Color :: DarkGrey ) ) ,
251+ (
252+ Meaning :: AlertWarn ,
253+ StyleFactory :: from_fg_color( Color :: Yellow ) ,
254+ ) ,
255+ (
256+ Meaning :: AlertInfo ,
257+ StyleFactory :: from_fg_color( Color :: Green ) ,
258+ ) ,
259+ (
260+ Meaning :: Annotation ,
261+ StyleFactory :: from_fg_color( Color :: DarkGrey ) ,
262+ ) ,
246263 ( Meaning :: Guidance , StyleFactory :: from_fg_color( Color :: Blue ) ) ,
247- ( Meaning :: Important , StyleFactory :: from_fg_color( Color :: White ) ) ,
264+ (
265+ Meaning :: Important ,
266+ StyleFactory :: from_fg_color( Color :: White ) ,
267+ ) ,
248268 ( Meaning :: Muted , StyleFactory :: from_fg_color( Color :: Grey ) ) ,
249269 ( Meaning :: Base , ContentStyle :: default ( ) ) ,
250- ] )
270+ ] ) ,
251271 )
252272 } ;
253273 static ref BUILTIN_THEMES : HashMap <& ' static str , Theme > = {
@@ -256,21 +276,42 @@ lazy_static! {
256276 (
257277 "autumn" ,
258278 HashMap :: from( [
259- ( Meaning :: AlertError , StyleFactory :: known_fg_string( "saddlebrown" ) ) ,
260- ( Meaning :: AlertWarn , StyleFactory :: known_fg_string( "darkorange" ) ) ,
279+ (
280+ Meaning :: AlertError ,
281+ StyleFactory :: known_fg_string( "saddlebrown" ) ,
282+ ) ,
283+ (
284+ Meaning :: AlertWarn ,
285+ StyleFactory :: known_fg_string( "darkorange" ) ,
286+ ) ,
261287 ( Meaning :: AlertInfo , StyleFactory :: known_fg_string( "gold" ) ) ,
262- ( Meaning :: Annotation , StyleFactory :: from_fg_color( Color :: DarkGrey ) ) ,
288+ (
289+ Meaning :: Annotation ,
290+ StyleFactory :: from_fg_color( Color :: DarkGrey ) ,
291+ ) ,
263292 ( Meaning :: Guidance , StyleFactory :: known_fg_string( "brown" ) ) ,
264293 ] ) ,
265294 ) ,
266295 (
267296 "marine" ,
268297 HashMap :: from( [
269- ( Meaning :: AlertError , StyleFactory :: known_fg_string( "yellowgreen" ) ) ,
298+ (
299+ Meaning :: AlertError ,
300+ StyleFactory :: known_fg_string( "yellowgreen" ) ,
301+ ) ,
270302 ( Meaning :: AlertWarn , StyleFactory :: known_fg_string( "cyan" ) ) ,
271- ( Meaning :: AlertInfo , StyleFactory :: known_fg_string( "turquoise" ) ) ,
272- ( Meaning :: Annotation , StyleFactory :: known_fg_string( "steelblue" ) ) ,
273- ( Meaning :: Base , StyleFactory :: known_fg_string( "lightsteelblue" ) ) ,
303+ (
304+ Meaning :: AlertInfo ,
305+ StyleFactory :: known_fg_string( "turquoise" ) ,
306+ ) ,
307+ (
308+ Meaning :: Annotation ,
309+ StyleFactory :: known_fg_string( "steelblue" ) ,
310+ ) ,
311+ (
312+ Meaning :: Base ,
313+ StyleFactory :: known_fg_string( "lightsteelblue" ) ,
314+ ) ,
274315 ( Meaning :: Guidance , StyleFactory :: known_fg_string( "teal" ) ) ,
275316 ] ) ,
276317 ) ,
@@ -430,7 +471,10 @@ mod theme_tests {
430471 let mytheme = Theme :: new (
431472 "mytheme" . to_string ( ) ,
432473 None ,
433- HashMap :: from ( [ ( Meaning :: AlertError , StyleFactory :: known_fg_string ( "yellowgreen" ) ) ] ) ,
474+ HashMap :: from ( [ (
475+ Meaning :: AlertError ,
476+ StyleFactory :: known_fg_string ( "yellowgreen" ) ,
477+ ) ] ) ,
434478 ) ;
435479 manager. loaded_themes . insert ( "mytheme" . to_string ( ) , mytheme) ;
436480 let theme = manager. load_theme ( "mytheme" , None ) ;
@@ -473,16 +517,10 @@ mod theme_tests {
473517 ) ;
474518
475519 // Does not fall back to any color.
476- assert_eq ! (
477- theme. as_style( Meaning :: AlertInfo ) . foreground_color,
478- None
479- ) ;
520+ assert_eq ! ( theme. as_style( Meaning :: AlertInfo ) . foreground_color, None ) ;
480521
481522 // Even for the base.
482- assert_eq ! (
483- theme. as_style( Meaning :: Base ) . foreground_color,
484- None
485- ) ;
523+ assert_eq ! ( theme. as_style( Meaning :: Base ) . foreground_color, None ) ;
486524
487525 // Falls back to red as meaning missing from theme, so picks base default.
488526 assert_eq ! (
@@ -536,7 +574,10 @@ mod theme_tests {
536574 assert_eq ! ( theme. get_warning( ) . foreground_color. unwrap( ) , Color :: Yellow ) ;
537575 assert_eq ! ( theme. get_info( ) . foreground_color. unwrap( ) , Color :: Green ) ;
538576 assert_eq ! ( theme. get_base( ) . foreground_color, None ) ;
539- assert_eq ! ( theme. get_alert( log:: Level :: Error ) . foreground_color. unwrap( ) , Color :: Red )
577+ assert_eq ! (
578+ theme. get_alert( log:: Level :: Error ) . foreground_color. unwrap( ) ,
579+ Color :: Red
580+ )
540581 }
541582
542583 #[ test]
0 commit comments