@@ -79,19 +79,13 @@ impl<'a, 'b> App<'a, 'b> {
79
79
/// let prog = App::new("My Program")
80
80
/// # ;
81
81
/// ```
82
- pub fn new < S : Into < String > > ( n : S ) -> Self {
83
- App { p : Parser :: with_name ( n. into ( ) ) }
84
- }
82
+ pub fn new < S : Into < String > > ( n : S ) -> Self { App { p : Parser :: with_name ( n. into ( ) ) } }
85
83
86
84
/// Get the name of the app
87
- pub fn get_name ( & self ) -> & str {
88
- & self . p . meta . name
89
- }
85
+ pub fn get_name ( & self ) -> & str { & self . p . meta . name }
90
86
91
87
/// Get the name of the binary
92
- pub fn get_bin_name ( & self ) -> Option < & str > {
93
- self . p . meta . bin_name . as_ref ( ) . map ( |s| s. as_str ( ) )
94
- }
88
+ pub fn get_bin_name ( & self ) -> Option < & str > { self . p . meta . bin_name . as_ref ( ) . map ( |s| s. as_str ( ) ) }
95
89
96
90
/// Creates a new instance of an application requiring a name, but uses the [`crate_authors!`]
97
91
/// and [`crate_version!`] macros to fill in the [`App::author`] and [`App::version`] fields.
@@ -155,9 +149,7 @@ impl<'a, 'b> App<'a, 'b> {
155
149
/// [`examples/17_yaml.yml`]: https://github.com/kbknapp/clap-rs/blob/master/examples/17_yaml.yml
156
150
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
157
151
#[ cfg( feature = "yaml" ) ]
158
- pub fn from_yaml ( yaml : & ' a Yaml ) -> App < ' a , ' a > {
159
- App :: from ( yaml)
160
- }
152
+ pub fn from_yaml ( yaml : & ' a Yaml ) -> App < ' a , ' a > { App :: from ( yaml) }
161
153
162
154
/// Sets a string of author(s) that will be displayed to the user when they
163
155
/// request the help information with `--help` or `-h`.
@@ -1193,9 +1185,7 @@ impl<'a, 'b> App<'a, 'b> {
1193
1185
/// .get_matches();
1194
1186
/// ```
1195
1187
/// [`env::args_os`]: https://doc.rust-lang.org/std/env/fn.args_os.html
1196
- pub fn get_matches ( self ) -> ArgMatches < ' a > {
1197
- self . get_matches_from ( & mut env:: args_os ( ) )
1198
- }
1188
+ pub fn get_matches ( self ) -> ArgMatches < ' a > { self . get_matches_from ( & mut env:: args_os ( ) ) }
1199
1189
1200
1190
/// Starts the parsing process. This method will return a [`clap::Result`] type instead of exiting
1201
1191
/// the process on failed parse. By default this method gets matches from [`env::args_os`]
@@ -1508,78 +1498,37 @@ impl<'a> From<&'a Yaml> for App<'a, 'a> {
1508
1498
}
1509
1499
1510
1500
impl < ' a , ' b > Clone for App < ' a , ' b > {
1511
- fn clone ( & self ) -> Self {
1512
- App { p : self . p . clone ( ) }
1513
- }
1501
+ fn clone ( & self ) -> Self { App { p : self . p . clone ( ) } }
1514
1502
}
1515
1503
1516
1504
impl < ' n , ' e > AnyArg < ' n , ' e > for App < ' n , ' e > {
1517
1505
fn name ( & self ) -> & ' n str {
1518
1506
unreachable ! ( "App struct does not support AnyArg::name, this is a bug!" )
1519
1507
}
1520
- fn kind ( & self ) -> ArgKind {
1521
- ArgKind :: Subcmd
1522
- }
1523
- fn overrides ( & self ) -> Option < & [ & ' e str ] > {
1524
- None
1525
- }
1526
- fn requires ( & self ) -> Option < & [ & ' e str ] > {
1527
- None
1528
- }
1529
- fn blacklist ( & self ) -> Option < & [ & ' e str ] > {
1530
- None
1531
- }
1532
- fn required_unless ( & self ) -> Option < & [ & ' e str ] > {
1533
- None
1534
- }
1535
- fn val_names ( & self ) -> Option < & VecMap < & ' e str > > {
1536
- None
1537
- }
1538
- fn is_set ( & self , _: ArgSettings ) -> bool {
1539
- false
1540
- }
1508
+ fn id ( & self ) -> usize { self . p . id }
1509
+ fn kind ( & self ) -> ArgKind { ArgKind :: Subcmd }
1510
+ fn overrides ( & self ) -> Option < & [ & ' e str ] > { None }
1511
+ fn requires ( & self ) -> Option < & [ & ' e str ] > { None }
1512
+ fn blacklist ( & self ) -> Option < & [ & ' e str ] > { None }
1513
+ fn required_unless ( & self ) -> Option < & [ & ' e str ] > { None }
1514
+ fn val_names ( & self ) -> Option < & VecMap < & ' e str > > { None }
1515
+ fn is_set ( & self , _: ArgSettings ) -> bool { false }
1541
1516
fn set ( & mut self , _: ArgSettings ) {
1542
1517
unreachable ! ( "App struct does not support AnyArg::set, this is a bug!" )
1543
1518
}
1544
- fn has_switch ( & self ) -> bool {
1545
- false
1546
- }
1547
- fn max_vals ( & self ) -> Option < u64 > {
1548
- None
1549
- }
1550
- fn num_vals ( & self ) -> Option < u64 > {
1551
- None
1552
- }
1553
- fn possible_vals ( & self ) -> Option < & [ & ' e str ] > {
1554
- None
1555
- }
1556
- fn validator ( & self ) -> Option < & Rc < Fn ( String ) -> StdResult < ( ) , String > > > {
1557
- None
1558
- }
1559
- fn min_vals ( & self ) -> Option < u64 > {
1560
- None
1561
- }
1562
- fn short ( & self ) -> Option < char > {
1563
- None
1564
- }
1565
- fn long ( & self ) -> Option < & ' e str > {
1566
- None
1567
- }
1568
- fn val_delim ( & self ) -> Option < char > {
1569
- None
1570
- }
1571
- fn takes_value ( & self ) -> bool {
1572
- true
1573
- }
1574
- fn help ( & self ) -> Option < & ' e str > {
1575
- self . p . meta . about
1576
- }
1577
- fn default_val ( & self ) -> Option < & ' n str > {
1578
- None
1579
- }
1580
- fn longest_filter ( & self ) -> bool {
1581
- true
1582
- }
1519
+ fn has_switch ( & self ) -> bool { false }
1520
+ fn max_vals ( & self ) -> Option < u64 > { None }
1521
+ fn num_vals ( & self ) -> Option < u64 > { None }
1522
+ fn possible_vals ( & self ) -> Option < & [ & ' e str ] > { None }
1523
+ fn validator ( & self ) -> Option < & Rc < Fn ( String ) -> StdResult < ( ) , String > > > { None }
1524
+ fn min_vals ( & self ) -> Option < u64 > { None }
1525
+ fn short ( & self ) -> Option < char > { None }
1526
+ fn long ( & self ) -> Option < & ' e str > { None }
1527
+ fn val_delim ( & self ) -> Option < char > { None }
1528
+ fn takes_value ( & self ) -> bool { true }
1529
+ fn help ( & self ) -> Option < & ' e str > { self . p . meta . about }
1530
+ fn default_val ( & self ) -> Option < & ' n str > { None }
1531
+ fn longest_filter ( & self ) -> bool { true }
1583
1532
fn aliases ( & self ) -> Option < Vec < & ' e str > > {
1584
1533
if let Some ( ref aliases) = self . p . meta . aliases {
1585
1534
let vis_aliases: Vec < _ > =
@@ -1596,7 +1545,5 @@ impl<'n, 'e> AnyArg<'n, 'e> for App<'n, 'e> {
1596
1545
}
1597
1546
1598
1547
impl < ' n , ' e > fmt:: Display for App < ' n , ' e > {
1599
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1600
- write ! ( f, "{}" , self . p. meta. name)
1601
- }
1548
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result { write ! ( f, "{}" , self . p. meta. name) }
1602
1549
}
0 commit comments