pub struct Alternative {
pub name: Ident,
pub index: usize,
pub fields: Vec<Field>,
pub origin: Origin<Variant>,
}Expand description
One alternative of a Variant.
Fields§
§name: Ident§index: usizePosition within its sum, 0..N-1 — the same fact a Field carries,
for the same reason: a node handed out on its own still knows where it
sits.
This is the only numbering a sum has. What a destination language does with it is its own business: one may transmit it to say which alternative is live, another may send a name instead.
fields: Vec<Field>The alternative’s payload, in declaration order. May be empty — a sum can
mix payload-carrying and payload-free alternatives, and only the presence
of some payload makes the type a Variant.
origin: Origin<Variant>The alternative as written: delimiters, attributes, doc comments.
Implementations§
Source§impl Alternative
impl Alternative
Trait Implementations§
Source§impl Clone for Alternative
impl Clone for Alternative
Source§fn clone(&self) -> Alternative
fn clone(&self) -> Alternative
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Send for Alternative
impl !Sync for Alternative
impl Freeze for Alternative
impl RefUnwindSafe for Alternative
impl Unpin for Alternative
impl UnsafeUnpin for Alternative
impl UnwindSafe for Alternative
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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