@@ -26,7 +26,6 @@ use std::{
26
26
result,
27
27
str:: FromStr ,
28
28
} ;
29
- use strum:: { IntoEnumIterator , EnumCount } ;
30
29
31
30
type Result < T > = result:: Result < T , Error > ;
32
31
@@ -320,7 +319,7 @@ impl fmt::Display for CommitInfo {
320
319
}
321
320
}
322
321
323
- #[ derive( PartialEq , Eq , EnumString , EnumCount , EnumIter , IntoStaticStr ) ]
322
+ #[ derive( PartialEq , Eq , EnumString , EnumVariantNames ) ]
324
323
#[ strum( serialize_all = "snake_case" ) ]
325
324
enum InfoFields {
326
325
Project ,
@@ -335,7 +334,6 @@ enum InfoFields {
335
334
LinesOfCode ,
336
335
Size ,
337
336
License ,
338
- UnrecognizedField ,
339
337
}
340
338
341
339
#[ derive( PartialEq , Eq , Hash , Clone , EnumString ) ]
@@ -449,21 +447,8 @@ fn main() -> Result<()> {
449
447
. multiple ( true )
450
448
. takes_value ( true )
451
449
. case_insensitive ( true )
452
- . possible_values ( & InfoFields :: iter ( )
453
- . take ( InfoFields :: count ( ) - 1 )
454
- . map ( |field| field. into ( ) )
455
- . collect :: < Vec < & str > > ( )
456
- . as_slice ( ) )
457
- . possible_value ( "" )
458
- . hide_possible_values ( true )
459
- . default_value ( "" )
460
- . hide_default_value ( true )
461
- . help ( & format ! ( "Disable fields to show\n Possible values: {:?}" ,
462
- & InfoFields :: iter( )
463
- . take( InfoFields :: count( ) - 1 )
464
- . map( |field| field. into( ) )
465
- . collect:: <Vec <& str >>( )
466
- . as_slice( ) ) ) )
450
+ . possible_values ( & InfoFields :: variants ( ) )
451
+ . help ( "Disable fields to show" ) )
467
452
. arg ( Arg :: with_name ( "colors" )
468
453
. short ( "c" )
469
454
. long ( "colors" )
@@ -519,11 +504,7 @@ Possible values: [{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11}{12}{13}{14}{15}]",
519
504
let disable_fields: Vec < InfoFields > = if let Some ( values) = matches. values_of ( "disable_field" ) {
520
505
values
521
506
. map ( String :: from)
522
- . filter_map ( |field : String | {
523
- let item = InfoFields :: from_str ( field. to_lowercase ( ) . as_str ( ) )
524
- . unwrap_or ( InfoFields :: UnrecognizedField ) ;
525
- if item == InfoFields :: UnrecognizedField { None } else { Some ( item) }
526
- } )
507
+ . map ( |field : String | InfoFields :: from_str ( field. to_lowercase ( ) . as_str ( ) ) . unwrap ( ) )
527
508
. collect ( )
528
509
} else {
529
510
Vec :: new ( )
0 commit comments