Enum syn_helpers::Fields

source ·
pub enum Fields {
    Named(Vec<NamedField>, Vec<Attribute>),
    Unnamed(Vec<UnnamedField>, Vec<Attribute>),
    Unit(Vec<Attribute>),
}
Expand description

Represents the fields in a structure. This could be the fields on a struct or the fields in the variant of a enum

Variants§

§

Named(Vec<NamedField>, Vec<Attribute>)

*name* { X: String }

§

Unnamed(Vec<UnnamedField>, Vec<Attribute>)

*name*(String)

§

Unit(Vec<Attribute>)

No fields *name*

Implementations§

source§

impl Fields

source

pub fn get_field_attributes(&self) -> &[Attribute]

source

pub fn fields_iterator( &self ) -> impl ExactSizeIterator<Item = NamedOrUnnamedField<'_>>

source

pub fn fields_iterator_mut( &mut self ) -> impl ExactSizeIterator<Item = NamedOrUnnamedFieldMut<'_>>

source

pub fn to_pattern(&self, path: Path, type_of_self: TypeOfSelf) -> TokenStream

source

pub fn to_pattern_with_config( &self, path: Path, type_of_self: TypeOfSelf, name_postfix: &'static str ) -> TokenStream

source

pub fn to_constructor<'b>( &'b self, generator: impl Fn(NamedOrUnnamedField<'b>) -> Result<Expr, Box<dyn Error>>, constructor: Path ) -> Result<Expr, Box<dyn Error>>

source

pub fn get_field_by_member( &self, member: Member ) -> Option<NamedOrUnnamedField<'_>>

Will just return None if member is not of matching form. Also will return None if cannot find the field

source

pub fn get_field_by_member_mut( &mut self, member: Member ) -> Option<NamedOrUnnamedFieldMut<'_>>

Will just return None if member is not of matching form. Also will return None if cannot find the field

Auto Trait Implementations§

§

impl RefUnwindSafe for Fields

§

impl !Send for Fields

§

impl !Sync for Fields

§

impl Unpin for Fields

§

impl UnwindSafe for Fields

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.