pub struct ExprVariant {
pub base: Box<Expr>,
pub variant: VariantId,
}Expand description
Selects a variant of an embedded enum value.
Evaluates to the payload of base when it holds variant: the record of
the variant’s fields, in declaration order, without the discriminant.
Projections applied to it index that record with the variant’s local
field positions, so project(variant(owner, Human), [1]) is the second
field of Owner::Human, whatever the enum’s storage layout.
The selection carries no check of its own. A predicate over a selection
must also require the variant; statement normalization in the engine
conjoins an is_variant check for every selection a
predicate’s operands reach. Lowering resolves the selection to the
variant’s column expressions and the guard to a discriminant comparison;
the node never reaches a driver.
§Examples
variant(owner, Owner::Human) // the Human payload
project(variant(owner, Owner::Human), [0]) // its first fieldFields§
§base: Box<Expr>Expression evaluating to an enum value.
variant: VariantIdThe variant whose payload is selected.
Trait Implementations§
Source§impl Clone for ExprVariant
impl Clone for ExprVariant
Source§fn clone(&self) -> ExprVariant
fn clone(&self) -> ExprVariant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExprVariant
impl Debug for ExprVariant
Source§impl From<ExprVariant> for Expr
impl From<ExprVariant> for Expr
Source§fn from(value: ExprVariant) -> Self
fn from(value: ExprVariant) -> Self
Source§impl PartialEq for ExprVariant
impl PartialEq for ExprVariant
Source§fn eq(&self, other: &ExprVariant) -> bool
fn eq(&self, other: &ExprVariant) -> bool
self and other values to be equal, and is used by ==.