pub enum Expr {
Literal(Literal),
Ident(String),
Binary {
left: Box<Expr>,
op: BinaryOp,
right: Box<Expr>,
span: Option<Span>,
},
Unary {
op: UnaryOp,
expr: Box<Expr>,
span: Option<Span>,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
span: Option<Span>,
},
Member {
object: Box<Expr>,
property: Box<Expr>,
computed: bool,
span: Option<Span>,
},
Array(Vec<Expr>),
Object(Vec<(String, Expr)>),
Function(Box<Function>),
Conditional {
test: Box<Expr>,
consequent: Box<Expr>,
alternate: Box<Expr>,
span: Option<Span>,
},
Assign {
target: Box<Expr>,
value: Box<Expr>,
span: Option<Span>,
},
TemplateLiteral(Vec<TemplatePart>),
}Expand description
An expression that produces a value.
Variants§
Literal(Literal)
Literal value.
Ident(String)
Variable reference.
Binary
Binary operation: left op right.
Fields
Unary
Unary operation: op expr.
Fields
Call
Function call: callee(args...).
Fields
Member
Member access: object.property or object[property].
Fields
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.
Fields
Assign
Assignment: target = value.
Fields
TemplateLiteral(Vec<TemplatePart>)
Template literal: `text${expr}more`.
Carries the original template structure for languages that support native string interpolation (TypeScript/JavaScript). Writers for other languages (Lua, Python) fall back to string concatenation.
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
pub fn template_literal(parts: Vec<TemplatePart>) -> 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 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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request