struct Expansion<'a> {
attrs: Option<&'a FieldConversion>,
ident: &'a Ident,
variant: Option<&'a Ident>,
fields: &'a Fields,
generics: &'a Generics,
has_explicit_from: bool,
}Expand description
Expansion of a macro for generating From implementation of a struct or
enum.
Fields§
§attrs: Option<&'a FieldConversion>From attributes.
As a VariantAttribute is superset of a StructAttribute, we use
it for both derives.
ident: &'a IdentStruct or enum syn::Ident.
variant: Option<&'a Ident>Variant syn::Ident in case of enum expansion.
fields: &'a FieldsStruct or variant syn::Fields.
generics: &'a GenericsStruct or enum syn::Generics.
has_explicit_from: boolIndicator whether one of the enum variants has
VariantAttribute::Empty, VariantAttribute::Types or
VariantAttribute::Forward.
Always false for structs.
Implementations§
Source§impl Expansion<'_>
impl Expansion<'_>
Sourcefn expand(&self) -> Result<TokenStream>
fn expand(&self) -> Result<TokenStream>
Expands From implementations for a struct or an enum variant.
Sourcefn expand_fields(
&self,
wrap: impl FnMut(Option<&Ident>, &Type, Option<Index>) -> TokenStream,
) -> TokenStream
fn expand_fields( &self, wrap: impl FnMut(Option<&Ident>, &Type, Option<Index>) -> TokenStream, ) -> TokenStream
Expands fields initialization wrapped into token::Braces in case of
syn::FieldsNamed, or token::Paren in case of
syn::FieldsUnnamed.
Auto Trait Implementations§
impl<'a> Freeze for Expansion<'a>
impl<'a> RefUnwindSafe for Expansion<'a>
impl<'a> !Send for Expansion<'a>
impl<'a> !Sync for Expansion<'a>
impl<'a> Unpin for Expansion<'a>
impl<'a> UnwindSafe for Expansion<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more