@@ -19,25 +19,23 @@ pub trait OptStore {
19
19
fn set_field_values ( & mut self , m : & HashMap < & str , Vec < & str > > ) -> Result < ( ) , InvalidOption > ;
20
20
}
21
21
22
- impl OptCfg {
23
- /// Makes a vector of [OptCfg] struct instances from the field definitions and `opt` field
24
- /// attributes of the struct instnace of which type is `T`.
25
- ///
26
- /// One [OptCfg] struct instance is made for each field.
27
- /// The field name is set to `store_key`.
28
- /// If the field's data type is `bool`, `has_arg` is set to `false`, otherwise, it is set to
29
- /// `true`.
30
- /// If the field is a vector type, `is_array` is set to `true`; otherwise, it is set to
31
- /// `false`.
32
- ///
33
- /// Additionally, `names`, `defaults`, `desc`, and `arg_in_help` are set with extracted from
34
- /// the `opt` attribute attached to the field.
35
- ///
36
- /// For `validator`, if the field's data type is numeric, it is set to the `validate_number`
37
- /// function pointer corresponding to the data type.
38
- pub fn make_cfgs_for < T : OptStore > ( opt_store : & mut T ) -> Vec < OptCfg > {
39
- opt_store. make_opt_cfgs ( )
40
- }
22
+ /// Makes a vector of [OptCfg] struct instances from the field definitions and `opt` field
23
+ /// attributes of the struct instnace of which type is `T`.
24
+ ///
25
+ /// One [OptCfg] struct instance is made for each field.
26
+ /// The field name is set to `store_key`.
27
+ /// If the field's data type is `bool`, `has_arg` is set to `false`, otherwise, it is set to
28
+ /// `true`.
29
+ /// If the field is a vector type, `is_array` is set to `true`; otherwise, it is set to
30
+ /// `false`.
31
+ ///
32
+ /// Additionally, `names`, `defaults`, `desc`, and `arg_in_help` are set with extracted from
33
+ /// the `opt` attribute attached to the field.
34
+ ///
35
+ /// For `validator`, if the field's data type is numeric, it is set to the `validate_number`
36
+ /// function pointer corresponding to the data type.
37
+ pub fn make_opt_cfgs_for < T : OptStore > ( opt_store : & mut T ) -> Vec < OptCfg > {
38
+ opt_store. make_opt_cfgs ( )
41
39
}
42
40
43
41
impl < ' b > Cmd < ' _ > {
@@ -180,7 +178,7 @@ impl<'b> Cmd<'_> {
180
178
}
181
179
182
180
#[ cfg( test) ]
183
- mod tests_of_make_cfgs_for {
181
+ mod tests_of_make_opt_cfgs_for {
184
182
use super :: * ;
185
183
use crate as cliargs;
186
184
extern crate cliargs_derive;
@@ -304,7 +302,7 @@ mod tests_of_make_cfgs_for {
304
302
#[ test]
305
303
fn test_make_opt_cfgs_for_opt_store ( ) {
306
304
let mut store = NoAttrOptions :: with_defaults ( ) ;
307
- let cfgs = cliargs:: OptCfg :: make_cfgs_for ( & mut store) ;
305
+ let cfgs = cliargs:: make_opt_cfgs_for ( & mut store) ;
308
306
assert_eq ! ( cfgs. len( ) , 40 ) ;
309
307
310
308
let cfg = & cfgs[ 0 ] ;
@@ -1084,7 +1082,7 @@ mod tests_of_make_cfgs_for {
1084
1082
#[ test]
1085
1083
fn test_make_opt_cfgs_for_store ( ) {
1086
1084
let mut store = WithAttrOptions :: with_defaults ( ) ;
1087
- let cfgs = cliargs:: OptCfg :: make_cfgs_for ( & mut store) ;
1085
+ let cfgs = cliargs:: make_opt_cfgs_for ( & mut store) ;
1088
1086
assert_eq ! ( cfgs. len( ) , 40 ) ;
1089
1087
1090
1088
let cfg = & cfgs[ 0 ] ;
@@ -1501,7 +1499,7 @@ mod tests_of_make_cfgs_for {
1501
1499
empty_str : Vec < String > ,
1502
1500
}
1503
1501
let mut store = MyOptions :: with_defaults ( ) ;
1504
- let cfgs = cliargs:: OptCfg :: make_cfgs_for ( & mut store) ;
1502
+ let cfgs = cliargs:: make_opt_cfgs_for ( & mut store) ;
1505
1503
assert_eq ! ( cfgs. len( ) , 4 ) ;
1506
1504
assert_eq ! ( cfgs[ 0 ] . store_key, "empty" . to_string( ) ) ;
1507
1505
assert_eq ! ( cfgs[ 0 ] . defaults, Some ( Vec :: <String >:: new( ) ) ) ;
0 commit comments