Skip to content

Commit

Permalink
Merge clap-rs#2888
Browse files Browse the repository at this point in the history
2888: refactor(derive): Simplify 'error' handling r=pksunkara a=epage



Co-authored-by: Ed Page <[email protected]>
  • Loading branch information
bors[bot] and epage authored Oct 15, 2021
2 parents bfd6f8d + 7b56184 commit 2795ccd
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions clap_derive/src/derives/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ fn gen_from_arg_matches(
Unnamed(ref fields) if fields.unnamed.len() == 1 => {
let ty = &fields.unnamed[0];
quote! {
if let Some(res) = <#ty as clap::FromArgMatches>::from_arg_matches(arg_matches) {
if <#ty as clap::Subcommand>::has_subcommand(name) {
let res = <#ty as clap::FromArgMatches>::from_arg_matches(arg_matches).unwrap();
return Some(#name :: #variant_name (res));
}
}
Expand Down Expand Up @@ -600,9 +601,7 @@ fn gen_update_from_arg_matches(
#( #subcommands ),*
s => {
#( #child_subcommands )*
if let Some(sub) = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches) {
*s = sub;
}
*s = <Self as clap::FromArgMatches>::from_arg_matches(arg_matches).unwrap();
}
}
}
Expand Down

0 comments on commit 2795ccd

Please sign in to comment.