pub enum VariantSelector {
Weight(f64),
When(Expr),
Else,
}Expand description
How one variant of a rule is selected during derivation.
Variants§
Weight(f64)
Stochastic: relative weight among the rule’s weighted variants
(70% ops | 30% ops). Weights need not sum to 1.
When(Expr)
Guarded: taken when the expression evaluates non-zero, top-down
(when(scope.x < 4): ops). A guarded rule’s variants are evaluated
in order; the first true guard wins.
Else
Fallback for a guarded rule (else: ops); must be last. In weighted
rules else: is parse-time sugar resolved into a Weight of the
remaining probability mass, so it never reaches the interpreter.
Trait Implementations§
Source§impl Clone for VariantSelector
impl Clone for VariantSelector
Source§fn clone(&self) -> VariantSelector
fn clone(&self) -> VariantSelector
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 moreSource§impl Debug for VariantSelector
impl Debug for VariantSelector
Source§impl<'de> Deserialize<'de> for VariantSelector
impl<'de> Deserialize<'de> for VariantSelector
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for VariantSelector
impl PartialEq for VariantSelector
Source§impl Serialize for VariantSelector
impl Serialize for VariantSelector
impl StructuralPartialEq for VariantSelector
Auto Trait Implementations§
impl Freeze for VariantSelector
impl RefUnwindSafe for VariantSelector
impl Send for VariantSelector
impl Sync for VariantSelector
impl Unpin for VariantSelector
impl UnsafeUnpin for VariantSelector
impl UnwindSafe for VariantSelector
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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