Struct darling::ast::Fields

source ·
pub struct Fields<T> {
    pub style: Style,
    pub fields: Vec<T>,
    /* private fields */
}
Expand description

Equivalent to syn::Fields, but replaces the AST element with a generic.

Fields§

§style: Style§fields: Vec<T>

Implementations§

source§

impl<T> Fields<T>

source

pub fn new(style: Style, fields: Vec<T>) -> Fields<T>

Creates a new Fields struct.

source

pub fn with_span(self, span: Span) -> Fields<T>

Adds a Span to Fields.

source

pub fn empty_from(vd: &Fields) -> Fields<T>

source

pub fn split(self) -> (Style, Vec<T>)

Splits the Fields into its style and fields for further processing. Returns an empty Vec for Unit data.

source

pub fn is_newtype(&self) -> bool

Returns true if this variant’s data makes it a newtype.

source

pub fn is_unit(&self) -> bool

source

pub fn is_tuple(&self) -> bool

source

pub fn is_struct(&self) -> bool

source

pub fn as_ref(&self) -> Fields<&T>

source

pub fn map<F, U>(self, map: F) -> Fields<U>where F: FnMut(T) -> U,

source

pub fn iter(&self) -> Iter<'_, T>

source

pub fn len(&self) -> usize

Returns the number of fields in the structure.

source

pub fn is_empty(&self) -> bool

Returns true if the Fields contains no fields.

source§

impl<F> Fields<F>where F: FromField,

source

pub fn try_from(fields: &Fields) -> Result<Fields<F>, Error>

Trait Implementations§

source§

impl<T> AsShape for Fields<T>

source§

fn as_shape(&self) -> Shape

Get the “shape” of a fields container.
source§

impl<T> Clone for Fields<T>where T: Clone,

source§

fn clone(&self) -> Fields<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Fields<T>where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T, U> From<(Style, U)> for Fields<T>where U: Into<Vec<T>>,

source§

fn from(_: (Style, U)) -> Fields<T>

Converts to this type from the input type.
source§

impl<T> From<Style> for Fields<T>

source§

fn from(style: Style) -> Fields<T>

Converts to this type from the input type.
source§

impl<T> IntoIterator for Fields<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <Fields<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> PartialEq for Fields<T>where T: PartialEq,

source§

fn eq(&self, other: &Fields<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> ToTokens for Fields<T>where T: ToTokens,

source§

fn to_tokens(&self, tokens: &mut TokenStream)

Write self to the given TokenStream. Read more
source§

fn to_token_stream(&self) -> TokenStream

Convert self directly into a TokenStream object. Read more
source§

fn into_token_stream(self) -> TokenStreamwhere Self: Sized,

Convert self directly into a TokenStream object. Read more
source§

impl<T> UsesLifetimes for Fields<T>where T: UsesLifetimes,

source§

fn uses_lifetimes<'a>( &self, options: &Options, lifetimes: &'a HashSet<Lifetime, BuildHasherDefault<FnvHasher>> ) -> HashSet<&'a Lifetime, BuildHasherDefault<FnvHasher>>

Returns the subset of the queried lifetimes that are used by the implementing syntax element. Read more
source§

fn uses_lifetimes_cloned( &self, options: &Options, lifetimes: &HashSet<Lifetime, BuildHasherDefault<FnvHasher>> ) -> HashSet<Lifetime, BuildHasherDefault<FnvHasher>>

Find all used lifetimes, then clone them and return that set.
source§

impl<T> UsesTypeParams for Fields<T>where T: UsesTypeParams,

source§

fn uses_type_params<'a>( &self, options: &Options, type_set: &'a HashSet<Ident, BuildHasherDefault<FnvHasher>> ) -> HashSet<&'a Ident, BuildHasherDefault<FnvHasher>>

Returns the subset of the queried type parameters that are used by the implementing syntax element. Read more
source§

fn uses_type_params_cloned( &self, options: &Options, type_set: &HashSet<Ident, BuildHasherDefault<FnvHasher>> ) -> HashSet<Ident, BuildHasherDefault<FnvHasher>>

Find all type params using uses_type_params, then clone the found values and return the set.
source§

impl<T> Eq for Fields<T>where T: Eq,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Fields<T>where T: RefUnwindSafe,

§

impl<T> !Send for Fields<T>

§

impl<T> !Sync for Fields<T>

§

impl<T> Unpin for Fields<T>where T: Unpin,

§

impl<T> UnwindSafe for Fields<T>where T: UnwindSafe,

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<'i, I, T> CollectLifetimes for Twhere T: IntoIterator<Item = &'i I>, I: 'i + UsesLifetimes,

source§

fn collect_lifetimes<'a>( self, options: &Options, lifetimes: &'a HashSet<Lifetime, BuildHasherDefault<FnvHasher>> ) -> HashSet<&'a Lifetime, BuildHasherDefault<FnvHasher>>

Consume an iterator, accumulating all lifetimes in the elements which occur in lifetimes.
source§

fn collect_lifetimes_cloned( self, options: &Options, lifetimes: &HashSet<Lifetime, BuildHasherDefault<FnvHasher>> ) -> HashSet<Lifetime, BuildHasherDefault<FnvHasher>>

Consume an iterator using collect_lifetimes, then clone all found lifetimes and return that set.
source§

impl<'i, T, I> CollectTypeParams for Twhere T: IntoIterator<Item = &'i I>, I: 'i + UsesTypeParams,

source§

fn collect_type_params<'a>( self, options: &Options, type_set: &'a HashSet<Ident, BuildHasherDefault<FnvHasher>> ) -> HashSet<&'a Ident, BuildHasherDefault<FnvHasher>>

Consume an iterator, accumulating all type parameters in the elements which occur in type_set.
source§

fn collect_type_params_cloned( self, options: &Options, type_set: &HashSet<Ident, BuildHasherDefault<FnvHasher>> ) -> HashSet<Ident, BuildHasherDefault<FnvHasher>>

Consume an iterator using collect_type_params, then clone all found type params and return that set.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Spanned for Twhere T: Spanned + ?Sized,

source§

fn span(&self) -> Span

Returns a Span covering the complete contents of this syntax tree node, or Span::call_site() if this node is empty.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.