Function macro_tools::generic_params::names
source · pub fn names<'a>(generics: &'a Generics) -> impl IterTrait<'a, &'a Ident>
Expand description
Extracts the names of type parameters, lifetimes, and const parameters from the given Generics
.
This function returns an iterator over the names of the parameters in the Generics
,
which can be useful for generating code that requires just the names of the parameters
without their associated bounds or default values.
§Arguments
generics
- TheGenerics
instance from which to extract parameter names.
§Returns
Returns an iterator over the names of the parameters.
§Examples
let generics : syn::Generics = parse_quote!
{
< T : Clone + Default, U, 'a, const N : usize >
};
let names : Vec< _ > = macro_tools::generic_params::names( &generics ).collect();
assert_eq!( names, vec!
[
&syn::Ident::new( "T", proc_macro2::Span::call_site() ),
&syn::Ident::new( "U", proc_macro2::Span::call_site() ),
&syn::Ident::new( "a", proc_macro2::Span::call_site() ),
&syn::Ident::new( "N", proc_macro2::Span::call_site() )
]);