mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
refactor(derive): Simplify needs for finding the inner type
This commit is contained in:
parent
58cf0ee446
commit
96ac83e260
2 changed files with 5 additions and 4 deletions
|
@ -241,7 +241,7 @@ pub fn gen_augment(
|
|||
}
|
||||
}
|
||||
Kind::Arg(ty) => {
|
||||
let convert_type = inner_type(**ty, &field.ty);
|
||||
let convert_type = inner_type(&field.ty);
|
||||
|
||||
let occurrences = *attrs.parser().kind == ParserKind::FromOccurrences;
|
||||
let flag = *attrs.parser().kind == ParserKind::FromFlag;
|
||||
|
@ -524,7 +524,7 @@ fn gen_parsers(
|
|||
let parser = attrs.parser();
|
||||
let func = &parser.func;
|
||||
let span = parser.kind.span();
|
||||
let convert_type = inner_type(**ty, &field.ty);
|
||||
let convert_type = inner_type(&field.ty);
|
||||
let id = attrs.id();
|
||||
let (get_one, get_many, deref, mut parse) = match *parser.kind {
|
||||
FromOccurrences => (
|
||||
|
|
|
@ -40,8 +40,9 @@ impl Ty {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn inner_type(ty: Ty, field_ty: &syn::Type) -> &syn::Type {
|
||||
match ty {
|
||||
pub fn inner_type(field_ty: &syn::Type) -> &syn::Type {
|
||||
let ty = Ty::from_syn_ty(field_ty);
|
||||
match *ty {
|
||||
Ty::Vec | Ty::Option => sub_type(field_ty).unwrap_or(field_ty),
|
||||
Ty::OptionOption | Ty::OptionVec => {
|
||||
sub_type(field_ty).and_then(sub_type).unwrap_or(field_ty)
|
||||
|
|
Loading…
Reference in a new issue