pub enum Expression {
Literal(Value),
Variable(String),
Binary {
left: Box<Expression>,
op: BinaryOperator,
right: Box<Expression>,
},
Unary {
op: UnaryOperator,
expr: Box<Expression>,
},
Function {
name: String,
args: Vec<Expression>,
},
}Expand description
A conditional expression.
Variants§
Literal(Value)
Literal value.
Variable(String)
Variable reference.
Binary
Binary operation.
Fields
§
left: Box<Expression>Left operand.
§
op: BinaryOperatorBinary operator.
§
right: Box<Expression>Right operand.
Unary
Unary operation.
Function
Function call.
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn binary(left: Expression, op: BinaryOperator, right: Expression) -> Self
pub fn binary(left: Expression, op: BinaryOperator, right: Expression) -> Self
Create a binary expression.
Sourcepub fn eq(left: Expression, right: Expression) -> Self
pub fn eq(left: Expression, right: Expression) -> Self
Create an equality expression.
Sourcepub fn and(left: Expression, right: Expression) -> Self
pub fn and(left: Expression, right: Expression) -> Self
Create a logical AND expression.
Sourcepub fn or(left: Expression, right: Expression) -> Self
pub fn or(left: Expression, right: Expression) -> Self
Create a logical OR expression.
Sourcepub fn logical_not(expr: Expression) -> Self
pub fn logical_not(expr: Expression) -> Self
Create a NOT expression.
Sourcepub fn evaluate(&self, context: &ExpressionContext) -> Result<Value>
pub fn evaluate(&self, context: &ExpressionContext) -> Result<Value>
Evaluate the expression.
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
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