Struct Field

pub struct Field { pub attrs: Vec<Attribute>, pub vis: Visibility, pub modifiers: FieldModifiers, pub ident: Option<Ident>, pub colon_token: Option<Colon>, pub ty: Type, pub default: Option<(Eq, Expr)> }

A field of a struct or enum variant.

Fields

attrs: Vec<Attribute>
vis: Visibility
modifiers: FieldModifiers

(Non-exhaustive) Additional optional information about a field.

ident: Option<Ident>

Name of the field, if any.

Fields of tuple structs have no names.

colon_token: Option<Colon>
ty: Type
default: Option<(Eq, Expr)>

Implementations

impl Field

fn parse_named(input: ParseStream<'_>) -> Result<Self>

Parses a named (braced struct) field.

fn parse_unnamed(input: ParseStream<'_>) -> Result<Self>

Parses an unnamed (tuple struct) field.

Trait Implementations

impl Clone for Field

fn clone(&self) -> Self

impl ToTokens for Field

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

Auto Trait Implementations

impl !Send for Field

impl !Sync for Field

impl Freeze for Field

impl RefUnwindSafe for Field

impl Unpin for Field

impl UnsafeUnpin for Field

impl UnwindSafe for Field

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> CloneToUninit for Field where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Field

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Spanned for Field where T: Spanned + ?Sized,

fn span(&self) -> Span

impl<T> ToOwned for Field where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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