pub enum Expr {
Literal(Literal),
Ident(String),
Binary {
left: Box<Expr>,
op: BinaryOp,
right: Box<Expr>,
},
Unary {
op: UnaryOp,
expr: Box<Expr>,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
},
Member {
object: Box<Expr>,
property: Box<Expr>,
computed: bool,
},
Array(Vec<Expr>),
Object(Vec<(String, Expr)>),
Function(Box<Function>),
Conditional {
test: Box<Expr>,
consequent: Box<Expr>,
alternate: Box<Expr>,
},
Assign {
target: Box<Expr>,
value: Box<Expr>,
},
}Expand description
An expression that produces a value.
Variants§
Literal(Literal)
Literal value.
Ident(String)
Variable reference.
Binary
Binary operation: left op right.
Unary
Unary operation: op expr.
Call
Function call: callee(args...).
Member
Member access: object.property or object[property].
Array(Vec<Expr>)
Array literal: [a, b, c].
Object(Vec<(String, Expr)>)
Object literal: { key: value, ... }.
Function(Box<Function>)
Anonymous function: function(params) { body }.
Conditional
Ternary/conditional: cond ? then : else.
Assign
Assignment: target = value.
Implementations§
Source§impl Expr
impl Expr
pub fn null() -> Self
pub fn bool(v: bool) -> Self
pub fn number(v: impl Into<f64>) -> Self
pub fn string(v: impl Into<String>) -> Self
pub fn ident(name: impl Into<String>) -> Self
pub fn binary(left: Expr, op: BinaryOp, right: Expr) -> Self
pub fn unary(op: UnaryOp, expr: Expr) -> Self
pub fn call(callee: Expr, args: Vec<Expr>) -> Self
pub fn member(object: Expr, property: impl Into<String>) -> Self
pub fn index(object: Expr, index: Expr) -> Self
pub fn array(items: Vec<Expr>) -> Self
pub fn object(pairs: Vec<(String, Expr)>) -> Self
pub fn conditional(test: Expr, consequent: Expr, alternate: Expr) -> Self
pub fn assign(target: Expr, value: Expr) -> Self
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
Source§impl StructureEq for Expr
impl StructureEq for Expr
Source§fn structure_eq(&self, other: &Self) -> bool
fn structure_eq(&self, other: &Self) -> bool
Compare two values for structural equality.
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