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: usizePosition 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
impl Field
Sourcepub fn member(&self) -> Member
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.
Sourcepub fn bind(&self, bind: &impl ToTokens) -> TokenStream
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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