Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 20 variants Literal(Literal), Null, Identifier(String), FieldAccess { receiver: Box<Expr>, field: String, }, BinaryOp { op: BinaryOperator, left: Box<Expr>, right: Box<Expr>, }, UnaryOp { op: UnaryOperator, operand: Box<Expr>, }, FunctionCall { name: String, args: Vec<Expr>, }, Lambda { param: String, body: Box<Expr>, }, Let { name: String, value: Box<Expr>, body: Box<Expr>, }, If { condition: Box<Expr>, then_branch: Box<Expr>, else_branch: Box<Expr>, }, Array(Vec<Expr>), Object(Vec<(String, Expr)>), Pipe { value: Box<Expr>, functions: Vec<Expr>, }, Alternative { primary: Box<Expr>, alternative: Box<Expr>, }, Guard { condition: Box<Expr>, body: Box<Expr>, }, Date(String), DateTime(String), Duration(String), TemporalKeyword(TemporalKeyword), String(String),
}
Expand description

Top-level ELO expression type

Represents any valid ELO expression that can be parsed and executed. This is an exhaustive enum of all expression forms in ELO.

Variants§

§

Literal(Literal)

Literal values: numbers (int/float) or booleans

§

Null

Null literal

§

Identifier(String)

Variable reference (identifier)

§

FieldAccess

Field access: receiver.field (e.g., user.age)

Fields

§receiver: Box<Expr>

The expression being accessed

§field: String

The field name

§

BinaryOp

Binary operation: left op right

Fields

§op: BinaryOperator

The binary operator

§left: Box<Expr>

Left operand

§right: Box<Expr>

Right operand

§

UnaryOp

Unary operation: op operand

Fields

§op: UnaryOperator

The unary operator

§operand: Box<Expr>

The operand

§

FunctionCall

Function call: name(args)

Fields

§name: String

Function name

§args: Vec<Expr>

Function arguments

§

Lambda

Lambda expression: param ~> body

Fields

§param: String

Parameter name

§body: Box<Expr>

Lambda body expression

§

Let

Let binding: let name = value in body

Fields

§name: String

Variable name being bound

§value: Box<Expr>

Value expression

§body: Box<Expr>

Body expression (scope where binding is available)

§

If

If conditional: if condition then branch_a else branch_b

Fields

§condition: Box<Expr>

Condition expression

§then_branch: Box<Expr>

Then branch

§else_branch: Box<Expr>

Else branch

§

Array(Vec<Expr>)

Array literal: [expr1, expr2, …]

§

Object(Vec<(String, Expr)>)

Object literal: {key1: value1, key2: value2, …}

§

Pipe

Pipe operator: expr |> func() |> …

Fields

§value: Box<Expr>

The value being piped

§functions: Vec<Expr>

Functions to pipe through (in order)

§

Alternative

Alternative operator: expr ?| default

Fields

§primary: Box<Expr>

Primary expression

§alternative: Box<Expr>

Alternative/default expression

§

Guard

Guard expression: guard condition in expr

Fields

§condition: Box<Expr>

Condition that must be true

§body: Box<Expr>

Expression to evaluate if guard passes

§

Date(String)

Date literal: @date(2024-01-15)

§

DateTime(String)

DateTime literal: @datetime(2024-01-15T10:30:00Z)

§

Duration(String)

Duration literal: @duration(P1D), @duration(PT1H30M)

§

TemporalKeyword(TemporalKeyword)

Temporal keyword: NOW, TODAY, TOMORROW, etc.

§

String(String)

String literal (explicitly quoted with single quotes)

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.