Struct darling_core::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>) -> Self

Creates a new Fields struct.

source

pub fn with_span(self, span: Span) -> Self

Adds a Span to Fields.

source

pub fn empty_from(vd: &Fields) -> Self

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: FromField> Fields<F>

source

pub fn try_from(fields: &Fields) -> Result<Self>

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> Clone for Fields<T>

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> Debug for Fields<T>

source§

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

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

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

source§

fn from((style, fields): (Style, U)) -> Self

Converts to this type from the input type.
source§

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

source§

fn from(style: Style) -> Self

Converts to this type from the input type.
source§

impl<T> IntoIterator for Fields<T>

source§

type Item = T

The type of the elements being iterated over.
source§

type IntoIter = IntoIter<T>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

source§

fn eq(&self, other: &Self) -> bool

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

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

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

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

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) -> TokenStream
where Self: Sized,

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

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

source§

fn uses_lifetimes<'a>( &self, options: &Options, lifetimes: &'a LifetimeSet, ) -> LifetimeRefSet<'a>

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: &LifetimeSet, ) -> LifetimeSet

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

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

source§

fn uses_type_params<'a>( &self, options: &Options, type_set: &'a IdentSet, ) -> IdentRefSet<'a>

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: &IdentSet, ) -> IdentSet

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

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

Auto Trait Implementations§

§

impl<T> Freeze for Fields<T>

§

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 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<'i, I, T> CollectLifetimes for T
where 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 T
where 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 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> Spanned for T
where 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 T
where T: Clone,

source§

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 T
where U: Into<T>,

source§

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

source§

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.