pub enum Expr {
Lit(f64),
Var(Var),
Unary(UnaryOp, Box<Expr>),
Binary(BinOp, Box<Expr>, Box<Expr>),
Call(Func, Vec<Expr>),
}Expand description
An argument expression, evaluated per shape at derivation time.
Variants§
Lit(f64)
Literal constant. The only node genetics mutates.
Var(Var)
Unary(UnaryOp, Box<Expr>)
Binary(BinOp, Box<Expr>, Box<Expr>)
Call(Func, Vec<Expr>)
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Total AST node count (self included). Used for the
MAX_EXPR_NODES DoS cap and as a cheap complexity metric.
Sourcepub fn as_lit(&self) -> Option<f64>
pub fn as_lit(&self) -> Option<f64>
Some(v) when the expression is a bare literal. Parse-time range
checks apply only to bare literals; everything else re-validates at
evaluation time.
Sourcepub fn visit_literals_mut(&mut self, f: &mut impl FnMut(&mut f64))
pub fn visit_literals_mut(&mut self, f: &mut impl FnMut(&mut f64))
Visits every literal leaf mutably — the genetics mutation hook.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
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
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
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,
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