Skip to main content

Field

Struct Field 

Source
pub struct Field {
    pub name: Option<Ident>,
    pub index: usize,
    pub ty: TypeRef,
    pub origin: Origin<Field>,
}
Expand description

One field of a Struct or of an Alternative.

Fields§

§name: Option<Ident>

The field’s name, or None for a positional one.

§index: usize

Position within its struct or alternative, 0..N-1 — the same fact an Alternative carries.

The address of a positional field. A named field has one too, and simply does not need it: it is addressed by name, so this is available rather than used — the same way it carries its item’s location.

§ty: TypeRef§origin: Origin<Field>

The field as written — pub id: u64, attributes and docs included.

Implementations§

Source§

impl Field

Source

pub fn docs(&self) -> Option<String>

This item’s /// documentation.

Source§

impl Field

Source

pub fn member(&self) -> Member

How the field is addressed in a pattern or an initializer: by name when it has one, else by position.

Ungated, and the reason is what it reads: name and index, both model facts. No captured syntax is involved, so this is not a door — unlike the spell methods above, which read the delimiters the source wrote and are Emit::shape’s to hand out.

Source

pub fn bind(&self, bind: &impl ToTokens) -> TokenStream

The field bound to bind, shaped for whichever address it uses — id: __f0 for a named field, __f0 for a positional one. The part a spelled fields list is built from.

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Field

Source§

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

Formats the value using the given formatter. Read more

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§

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.