fn descend_type(ty: &mut Type, op: impl Fn(&mut Type) -> Option<()>) -> Option<()> {
    match ty {
        Type::Array(x) => op(&mut x.elem),
        Type::Group(x) => op(&mut x.elem),
        Type::Never(_) => Some(()),
        Type::Paren(x) => op(&mut x.elem),
        Type::Path(x) => {
            if let Some(qself) = &mut x.qself {
                op(&mut qself.ty)?;
            }
            for p in x.path.segments.iter_mut() {
                match &mut p.arguments {
                    PathArguments::None => {}
                    PathArguments::AngleBracketed(x) => {
                        x.args.iter_mut().try_for_each(|x| match x {
                            GenericArgument::Type(x) => op(x),
                            _ => Some(()),
                        })?
                    }
                    PathArguments::Parenthesized(x) => {
                        x.inputs.iter_mut().try_for_each(&op)?;
                        if let ReturnType::Type(_, ty) = &mut x.output {
                            op(ty)?;
                        }
                    }
                }
            }
            Some(())
        }
        Type::Ptr(x) => op(&mut x.elem),
        Type::Reference(x) => op(&mut x.elem),
        Type::Slice(x) => op(&mut x.elem),
        Type::Tuple(xs) => xs.elems.iter_mut().try_for_each(op),
        _ => None,
    }
}
/// Descend into all the nested type values within a type, or return None if you don't know how
Descend into all the nested type values within a type, or return None if you don't know how
Descend into all the nested type values within a type or return None if you don ' t know how
fn descend_type(ty: &mut Type, op: impl Fn(&mut Type) -> Option<()>) -> Option<()> {
    match ty {
        Type::Array(x) => op(&mut x.elem),
        Type::Group(x) => op(&mut x.elem),
        Type::Never(_) => Some(()),
        Type::Paren(x) => op(&mut x.elem),
        Type::Path(x) => {
            if let Some(qself) = &mut x.qself {
                op(&mut qself.ty)?;
            }
            for p in x.path.segments.iter_mut() {
                match &mut p.arguments {
                    PathArguments::None => {}
                    PathArguments::AngleBracketed(x) => {
                        x.args.iter_mut().try_for_each(|x| match x {
                            GenericArgument::Type(x) => op(x),
                            _ => Some(()),
                        })?
                    }
                    PathArguments::Parenthesized(x) => {
                        x.inputs.iter_mut().try_for_each(&op)?;
                        if let ReturnType::Type(_, ty) = &mut x.output {
                            op(ty)?;
                        }
                    }
                }
            }
            Some(())
        }
        Type::Ptr(x) => op(&mut x.elem),
        Type::Reference(x) => op(&mut x.elem),
        Type::Slice(x) => op(&mut x.elem),
        Type::Tuple(xs) => xs.elems.iter_mut().try_for_each(op),
        _ => None,
    }
}
fn descend_type ( ty : & mut Type , op : impl Fn ( & mut Type ) -> Option < ( ) > ) -> Option < ( ) > { match ty { Type :: Array ( x ) => op ( & mut x . elem ) , Type :: Group ( x ) => op ( & mut x . elem ) , Type :: Never ( _ ) => Some ( ( ) ) , Type :: Paren ( x ) => op ( & mut x . elem ) , Type :: Path ( x ) => { if let Some ( qself ) = & mut x . qself { op ( & mut qself . ty ) ? ; } for p in x . path . segments . iter_mut ( ) { match & mut p . arguments { PathArguments :: None => { } PathArguments :: AngleBracketed ( x ) => { x . args . iter_mut ( ) . try_for_each ( | x | match x { GenericArgument :: Type ( x ) => op ( x ) , _ => Some ( ( ) ) , } ) ? } PathArguments :: Parenthesized ( x ) => { x . inputs . iter_mut ( ) . try_for_each ( & op ) ? ; if let ReturnType :: Type ( _ , ty ) = & mut x . output { op ( ty ) ? ; } } } } Some ( ( ) ) } Type :: Ptr ( x ) => op ( & mut x . elem ) , Type :: Reference ( x ) => op ( & mut x . elem ) , Type :: Slice ( x ) => op ( & mut x . elem ) , Type :: Tuple ( xs ) => xs . elems . iter_mut ( ) . try_for_each ( op ) , _ => None , } }
Descend into all the nested type values within a type, or return None if you don't know how
Descend into all the nested type values within a type or return None if you don ' t know how
ty
&mut Type
op
impl Fn(&mut Type) -> Option<()>
ty
&mut Type
op
impl Fn(&mut Type) -> Option<()>