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 Iterator<Item = NamedOrUnnamedField<'_>> + ExactSizeIterator

source

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

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>>

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 Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.