pub enum Expr {
FieldAccess(FieldAccessExpr),
SharedFieldAccess(SharedFieldAccessExpr),
MethodCall(MethodCallExpr),
BinaryOp(BinaryOpExpr),
UnaryOp(UnaryOpExpr),
Conditional(ConditionalExpr),
Literal(LiteralExpr),
}Expand description
Expression AST node
Variants§
FieldAccess(FieldAccessExpr)
Field access on the local model: {field} or {model.field.subfield}
Field access on the shared context: {shared.field} or {shared.field.subfield}
MethodCall(MethodCallExpr)
BinaryOp(BinaryOpExpr)
UnaryOp(UnaryOpExpr)
Conditional(ConditionalExpr)
Literal(LiteralExpr)
Implementations§
Source§impl Expr
impl Expr
Check if this expression accesses shared state.
Returns true if this expression or any of its sub-expressions
reference shared state via {shared.field} syntax.
§Examples
use dampen_core::expr::{Expr, SharedFieldAccessExpr, FieldAccessExpr};
// Shared field access
let shared_expr = Expr::SharedFieldAccess(SharedFieldAccessExpr {
path: vec!["theme".to_string()],
});
assert!(shared_expr.uses_shared());
// Regular field access
let regular_expr = Expr::FieldAccess(FieldAccessExpr {
path: vec!["count".to_string()],
});
assert!(!regular_expr.uses_shared());Sourcepub fn uses_model(&self) -> bool
pub fn uses_model(&self) -> bool
Check if this expression accesses the local model.
Returns true if this expression or any of its sub-expressions
reference local model fields via {field} syntax.
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 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