Function macro_tools::derive::named_fields
source · pub fn named_fields<'a>(
ast: &'a DeriveInput,
) -> Result<&'a Punctuated<Field, Comma>>
Expand description
Extracts the named fields from a struct defined in a syn::DeriveInput
.
This function specifically handles syn::DeriveInput
that represent structs
with named fields. It will return an error if the provided AST does not conform to these expectations.
§Example
ⓘ
let ast = match syn::parse::< syn::DeriveInput >( input )
{
Ok( syntax_tree ) => syntax_tree,
Err( err ) => return Err( err ),
};
let fields = derive.named_fields( &ast );