Expr

Enum Expr 

Source
pub enum Expr {
Show 14 variants Literal(Value), Variable(String), GetAttr { base: Box<Expr>, attr: String, }, GetItem { base: Box<Expr>, index: Box<Expr>, }, Slice { start: Option<Box<Expr>>, stop: Option<Box<Expr>>, step: Option<Box<Expr>>, }, Call { callee: Box<Expr>, args: Vec<Expr>, kwargs: Vec<(String, Expr)>, }, Filter { name: String, input: Box<Expr>, args: Vec<Expr>, }, List(Vec<Expr>), Dict(Vec<(Expr, Expr)>), InlineIf { cond: Box<Expr>, then_expr: Box<Expr>, else_expr: Option<Box<Expr>>, }, Unary { op: UnaryOp, expr: Box<Expr>, }, Binary { op: BinOp, left: Box<Expr>, right: Box<Expr>, }, Compare { head: Box<Expr>, rest: Vec<(CompareOp, Expr)>, }, RegexLiteral { pattern: String, flags: String, },
}
Expand description

Expression inside a variable tag or tag body (when wired up).

Variants§

§

Literal(Value)

JSON literal (numbers, strings, booleans, null).

§

Variable(String)

Context key; non-existent keys render as empty (Nunjucks-style).

§

GetAttr

Attribute access: base.attr (Nunjucks LookupVal).

Fields

§base: Box<Expr>
§attr: String
§

GetItem

Subscript: base[index] or Jinja-style base[start:stop:step].

Fields

§base: Box<Expr>
§index: Box<Expr>

Single index, or Expr::Slice for : subscripts.

§

Slice

Slice inside [ … ] (start:stop:step; any part may be omitted).

Fields

§start: Option<Box<Expr>>
§stop: Option<Box<Expr>>
§step: Option<Box<Expr>>
§

Call

Function-style call callee(args…) (runtime may be limited until globals exist).

Fields

§callee: Box<Expr>
§args: Vec<Expr>
§kwargs: Vec<(String, Expr)>

name = value arguments (applied after positionals; unknown names ignored, Nunjucks-style).

§

Filter

Filter pipeline step: input | name or input | name(arg, …).

Fields

§name: String
§input: Box<Expr>
§args: Vec<Expr>
§

List(Vec<Expr>)

Array literal [a, b, …] with arbitrary expressions.

§

Dict(Vec<(Expr, Expr)>)

Object literal { key: val, …} (keys are expressions, usually strings or identifiers).

§

InlineIf

Python-style conditional: body if cond else else_.

Fields

§cond: Box<Expr>
§then_expr: Box<Expr>
§else_expr: Option<Box<Expr>>
§

Unary

Fields

§expr: Box<Expr>
§

Binary

Fields

§left: Box<Expr>
§right: Box<Expr>
§

Compare

Chained comparisons (a == b < c → left-associative JS-style emit in Nunjucks).

Fields

§head: Box<Expr>
§rest: Vec<(CompareOp, Expr)>
§

RegexLiteral

JavaScript-style regex literal r/pattern/flags (Nunjucks lexer).

Fields

§pattern: String

Raw pattern body between slashes (may contain \/ escapes).

§flags: String

Flag letters g, i, m, y (subset of ECMAScript).

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V