pub enum Expression {
Literal {
value: Literal,
},
Ref {
name: ParameterName,
},
BinOp {
op: BinOp,
lhs: Box<Self>,
rhs: Box<Self>,
},
UnOp {
op: UnOp,
arg: Box<Self>,
},
Call {
func: BuiltinFn,
args: Vec<Self>,
},
If {
cond: Box<Self>,
then_: Box<Self>,
else_: Box<Self>,
},
}Expand description
An expression tree. Serde-able end to end.
Variants§
Literal
Literal value.
Ref
Reference to a previously-bound parameter value.
Fields
§
name: ParameterNameThe parameter name.
BinOp
Binary operation.
UnOp
Unary operation.
Call
Built-in function call.
If
Conditional (ternary).
Implementations§
Source§impl Expression
impl Expression
Sourcepub const fn reference(name: ParameterName) -> Self
pub const fn reference(name: ParameterName) -> Self
Convenience constructor for a parameter reference.
Sourcepub fn binop(op: BinOp, lhs: Self, rhs: Self) -> Self
pub fn binop(op: BinOp, lhs: Self, rhs: Self) -> Self
Convenience constructor for a binary operation.
Sourcepub const fn call(func: BuiltinFn, args: Vec<Self>) -> Self
pub const fn call(func: BuiltinFn, args: Vec<Self>) -> Self
Convenience constructor for a builtin call.
Sourcepub fn if_then_else(cond: Self, then_: Self, else_: Self) -> Self
pub fn if_then_else(cond: Self, then_: Self, else_: Self) -> Self
Convenience constructor for an if-expression.
Sourcepub fn eval(
&self,
bindings: &ValueBindings,
) -> Result<EvalValue, DerivationError>
pub fn eval( &self, bindings: &ValueBindings, ) -> Result<EvalValue, DerivationError>
Evaluate this expression against the given bindings.
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 · 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 Expression
impl Debug for Expression
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
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 Expression
impl PartialEq for Expression
Source§impl Serialize for Expression
impl Serialize for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expression
impl UnwindSafe for Expression
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