Enum Fields
enum Fields
Data stored within an enum variant or struct.
Syntax tree enum
This type is a syntax tree enum.
Variants
-
Named(FieldsNamed) Named fields of a struct or struct variant such as
Point { x: f64, y: f64 }.-
Unnamed(FieldsUnnamed) Unnamed fields of a tuple struct or tuple variant such as
Some(T).-
Unit Unit struct or unit variant such as
None.
Implementations
impl Fields
fn iter(self: &Self) -> Iter<'_, Field>Get an iterator over the borrowed
Fielditems in this object. This iterator can be used to iterate over a named or unnamed struct or variant's fields uniformly.fn iter_mut(self: &mut Self) -> IterMut<'_, Field>Get an iterator over the mutably borrowed
Fielditems in this object. This iterator can be used to iterate over a named or unnamed struct or variant's fields uniformly.fn len(self: &Self) -> usizeReturns the number of fields.
fn is_empty(self: &Self) -> boolReturns
trueif there are zero fields.fn members(self: &Self) -> Members<'_>Get an iterator over the fields of a struct or variant as
Members. This iterator can be used to iterate over a named or unnamed struct or variant's fields uniformly.Example
The following is a simplistic
Clonederive for structs. (A more complete implementation would additionally want to infer trait bounds on the generic type parameters.)# use quote; #For structs with named fields, it produces an expression like
Self { a: self.a.clone() }. For structs with unnamed fields,Self { 0: self.0.clone() }. And for unit structs,Self {}.
impl Clone for Fields
fn clone(self: &Self) -> Self
impl Debug for Fields
fn fmt(self: &Self, formatter: &mut Formatter<'_>) -> Result
impl Eq for Fields
impl Freeze for Fields
impl From for Fields
fn from(e: FieldsUnnamed) -> Fields
impl From for Fields
fn from(e: FieldsNamed) -> Fields
impl Hash for Fields
fn hash<H>(self: &Self, state: &mut H) where H: Hasher
impl IntoIterator for Fields
fn into_iter(self: Self) -> <Self as >::IntoIter
impl PartialEq for Fields
fn eq(self: &Self, other: &Self) -> bool
impl RefUnwindSafe for Fields
impl Send for Fields
impl Sync for Fields
impl ToTokens for Fields
fn to_tokens(self: &Self, tokens: &mut TokenStream)
impl Unpin for Fields
impl UnsafeUnpin for Fields
impl UnwindSafe for Fields
impl<T> Any for Fields
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Fields
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Fields
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Fields
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Fields
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Spanned for Fields
fn span(self: &Self) -> Span
impl<T> ToOwned for Fields
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Fields
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Fields
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Fields
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>