@@ -41,6 +41,7 @@ use args::{ FlagBuilder, OptBuilder, PosBuilder};
41
41
pub struct App < ' a , ' v , ' ab , ' u , ' h , ' ar > {
42
42
// The name displayed to the user when showing version and help/usage information
43
43
name : String ,
44
+ name_slice : & ' ar str ,
44
45
// A string of author(s) if desired. Displayed when showing help/usage information
45
46
author : Option < & ' a str > ,
46
47
// The version displayed to the user
@@ -86,9 +87,10 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
86
87
/// let prog = App::new("myprog")
87
88
/// # .get_matches();
88
89
/// ```
89
- pub fn new < ' n > ( n : & ' n str ) -> App < ' a , ' v , ' ab , ' u , ' h , ' ar > {
90
+ pub fn new ( n : & ' ar str ) -> App < ' a , ' v , ' ab , ' u , ' h , ' ar > {
90
91
App {
91
92
name : n. to_owned ( ) ,
93
+ name_slice : n,
92
94
author : None ,
93
95
about : None ,
94
96
more_help : None ,
@@ -725,7 +727,6 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
725
727
}
726
728
727
729
// Used when spacing arguments and their help message when displaying help information
728
- #[ inline( always) ]
729
730
fn get_spaces ( & self , num : usize ) -> & ' static str {
730
731
match num {
731
732
0 => "" ,
@@ -785,7 +786,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
785
786
786
787
// Starts the parsing process. Called on top level parent app **ONLY** then recursively calls
787
788
// the real parsing function for subcommands
788
- pub fn get_matches ( mut self ) -> ArgMatches < ' ar > {
789
+ pub fn get_matches ( mut self ) -> ArgMatches < ' ar , ' ar > {
789
790
self . verify_positionals ( ) ;
790
791
for ( _, sc) in self . subcommands . iter_mut ( ) {
791
792
sc. verify_positionals ( ) ;
@@ -844,7 +845,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
844
845
}
845
846
}
846
847
847
- fn get_matches_from ( & mut self , matches : & mut ArgMatches < ' ar > , it : & mut IntoIter < String > ) {
848
+ fn get_matches_from ( & mut self , matches : & mut ArgMatches < ' ar , ' ar > , it : & mut IntoIter < String > ) {
848
849
self . create_help_and_version ( ) ;
849
850
850
851
let mut pos_only = false ;
@@ -951,7 +952,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
951
952
// Was an update made, or is this the first occurrence?
952
953
if !done {
953
954
matches. args . insert ( p. name , MatchedArg {
954
- name : p. name . to_owned ( ) ,
955
+ // name: p.name.to_owned(),
955
956
occurrences : 1 ,
956
957
values : Some ( vec ! [ arg. clone( ) ] ) ,
957
958
} ) ;
@@ -1008,7 +1009,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1008
1009
sc. bin_name = Some ( format ! ( "{}{}{}" , self . bin_name. clone( ) . unwrap_or( "" . to_owned( ) ) , if self . bin_name. is_some( ) { " " } else { "" } , sc. name. clone( ) ) ) ;
1009
1010
sc. get_matches_from ( & mut new_matches, it) ;
1010
1011
matches. subcommand = Some ( Box :: new ( SubCommand {
1011
- name : sc. name . clone ( ) ,
1012
+ name : sc. name_slice ,
1012
1013
matches : new_matches} ) ) ;
1013
1014
}
1014
1015
}
@@ -1060,7 +1061,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1060
1061
}
1061
1062
}
1062
1063
1063
- fn parse_long_arg ( & mut self , matches : & mut ArgMatches < ' ar > , full_arg : & String ) -> Option < & ' ar str > {
1064
+ fn parse_long_arg ( & mut self , matches : & mut ArgMatches < ' ar , ' ar > , full_arg : & String ) -> Option < & ' ar str > {
1064
1065
let mut arg = full_arg. trim_left_matches ( |c| c == '-' ) ;
1065
1066
1066
1067
if arg == "help" && self . needs_long_help {
@@ -1116,7 +1117,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1116
1117
}
1117
1118
} else {
1118
1119
matches. args . insert ( v. name , MatchedArg {
1119
- name : v. name . to_owned ( ) ,
1120
+ // name: v.name.to_owned(),
1120
1121
occurrences : if arg_val. is_some ( ) { 1 } else { 0 } ,
1121
1122
values : if arg_val. is_some ( ) { Some ( vec ! [ arg_val. clone( ) . unwrap( ) ] ) } else { Some ( vec ! [ ] ) }
1122
1123
} ) ;
@@ -1167,7 +1168,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1167
1168
}
1168
1169
if !done {
1169
1170
matches. args . insert ( v. name , MatchedArg {
1170
- name : v. name . to_owned ( ) ,
1171
+ // name: v.name.to_owned(),
1171
1172
occurrences : 1 ,
1172
1173
values : None
1173
1174
} ) ;
@@ -1203,7 +1204,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1203
1204
unreachable ! ( ) ;
1204
1205
}
1205
1206
1206
- fn parse_short_arg ( & mut self , matches : & mut ArgMatches < ' ar > , full_arg : & String ) -> Option < & ' ar str > {
1207
+ fn parse_short_arg ( & mut self , matches : & mut ArgMatches < ' ar , ' ar > , full_arg : & String ) -> Option < & ' ar str > {
1207
1208
let arg = & full_arg[ ..] . trim_left_matches ( |c| c == '-' ) ;
1208
1209
if arg. len ( ) > 1 {
1209
1210
// Multiple flags using short i.e. -bgHlS
@@ -1239,7 +1240,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1239
1240
}
1240
1241
} else {
1241
1242
matches. args . insert ( v. name , MatchedArg {
1242
- name : v. name . to_owned ( ) ,
1243
+ // name: v.name.to_owned(),
1243
1244
// occurrences will be incremented on getting a value
1244
1245
occurrences : 0 ,
1245
1246
values : Some ( vec ! [ ] )
@@ -1273,7 +1274,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1273
1274
unreachable ! ( ) ;
1274
1275
}
1275
1276
1276
- fn parse_single_short_flag ( & mut self , matches : & mut ArgMatches < ' ar > , arg : char ) -> bool {
1277
+ fn parse_single_short_flag ( & mut self , matches : & mut ArgMatches < ' ar , ' ar > , arg : char ) -> bool {
1277
1278
for v in self . flags . values ( ) . filter ( |& v| v. short . is_some ( ) ) . filter ( |& v| v. short . unwrap ( ) == arg) {
1278
1279
// Ensure this flag isn't on the mutually excludes list
1279
1280
if self . blacklist . contains ( v. name ) {
@@ -1293,7 +1294,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1293
1294
}
1294
1295
if !done {
1295
1296
matches. args . insert ( v. name , MatchedArg {
1296
- name : v. name . to_owned ( ) ,
1297
+ // name: v.name.to_owned(),
1297
1298
occurrences : 1 ,
1298
1299
values : None
1299
1300
} ) ;
@@ -1325,7 +1326,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
1325
1326
false
1326
1327
}
1327
1328
1328
- fn validate_blacklist ( & self , matches : & ArgMatches < ' ar > ) {
1329
+ fn validate_blacklist ( & self , matches : & ArgMatches < ' ar , ' ar > ) {
1329
1330
for name in self . blacklist . iter ( ) {
1330
1331
if matches. args . contains_key ( name) {
1331
1332
self . report_error ( format ! ( "The argument {} cannot be used with one or more of the other specified arguments" ,
0 commit comments