fn includes_generic_type(ty: &syn::Type, generics: &[Ident]) -> bool {
    let path = match ty {
        syn::Type::Path(syn::TypePath { path, .. }) => path,
        _ => return false,
    };

    let last_seg = path.segments.last().unwrap();
    if generics.contains(&last_seg.ident) {
        return true;
    }

    match &last_seg.arguments {
        syn::PathArguments::AngleBracketed(args) => args.args.iter().any(|arg| {
            if let syn::GenericArgument::Type(ty) = arg {
                includes_generic_type(ty, generics)
            } else {
                false
            }
        }),
        _ => false,
    }
}
/// check if a struct field's type includes one of the generic paramaters
/// declared by that struct.
///
/// If it does, we can't generate const code.
check if a struct field's type includes one of the generic paramaters
declared by that struct.

If it does, we can't generate const code.
check if a struct field ' s type includes one of the generic paramaters declared by that struct . If it does we can ' t generate const code .
fn includes_generic_type(ty: &syn::Type, generics: &[Ident]) -> bool {
    let path = match ty {
        syn::Type::Path(syn::TypePath { path, .. }) => path,
        _ => return false,
    };
    let last_seg = path.segments.last().unwrap();
    if generics.contains(&last_seg.ident) {
        return true;
    }
    match &last_seg.arguments {
        syn::PathArguments::AngleBracketed(args) => args.args.iter().any(|arg| {
            if let syn::GenericArgument::Type(ty) = arg {
                includes_generic_type(ty, generics)
            } else {
                false
            }
        }),
        _ => false,
    }
}
fn includes_generic_type ( ty : & syn :: Type , generics : & [ Ident ] ) -> bool { let path = match ty { syn :: Type :: Path ( syn :: TypePath { path , .. } ) => path , _ => return false , } ; let last_seg = path . segments . last ( ) . unwrap ( ) ; if generics . contains ( & last_seg . ident ) { return true ; } match & last_seg . arguments { syn :: PathArguments :: AngleBracketed ( args ) => args . args . iter ( ) . any ( | arg | { if let syn :: GenericArgument :: Type ( ty ) = arg { includes_generic_type ( ty , generics ) } else { false } } ) , _ => false , } }
check if a struct field's type includes one of the generic paramaters
declared by that struct.
check if a struct field ' s type includes one of the generic paramaters declared by that struct .
ty
&syn::Type
generics
&[Ident]
ty
&syn::Type
generics
&[Ident]