Skip to main content

Expr

Enum Expr 

Source
#[non_exhaustive]
pub enum Expr {
Show 20 variants Null, Bool(bool), Int(i64), Float(f64), String(SmolStr), Var(VarId), Prop { target: Box<Expr>, prop: SmolStr, }, Index { target: Box<Expr>, index: Box<Expr>, }, Slice { target: Box<Expr>, start: Option<Box<Expr>>, end: Option<Box<Expr>>, }, List(Vec<Expr>), Map(Vec<(SmolStr, Expr)>), Call { func: SmolStr, args: Vec<Expr>, }, BinOp { op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, }, UnaryOp { op: UnaryOp, operand: Box<Expr>, }, Case { scrutinee: Option<Box<Expr>>, arms: Vec<(Expr, Expr)>, otherwise: Option<Box<Expr>>, }, IsNull { operand: Box<Expr>, negated: bool, }, InList { operand: Box<Expr>, list: Box<Expr>, }, ListPredicate { kind: ListPredKind, var: VarId, iterable: Box<Expr>, predicate: Option<Box<Expr>>, }, Param { name: SmolStr, }, Exists { pattern: Box<ReadOp>, },
}
Expand description

Plan-level expression IR. Spec §12.2.

Every variable reference carries its VarId; every function call is resolved by name. This is a distinct type from cyrs_hir::Expr: it is fully resolved (no cyrs_hir::Expr::Unresolved, no cyrs_hir::Expr::PatternPredicate, no MapProjection), and VarIds are plan-scoped rather than HIR-scoped (spec §12.3). The HIR→Plan lowering pass (bead cy-foy) maps between them.

§Equality of floats

Eq is manually implemented so that aggregates of Expr can derive Eq. Semantic equality for execution (e.g. NaN != NaN) is the consumer’s responsibility. The Plan IR treats float bit patterns as opaque for structural equality checks (spec §17.14 determinism).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Null

The null literal. Spec §12.2 E1.

§

Bool(bool)

A boolean literal (true / false). Spec §12.2 E2.

§

Int(i64)

A 64-bit signed integer literal. Spec §12.2 E3.

§

Float(f64)

A 64-bit IEEE-754 float literal. Spec §12.2 E4.

§

String(SmolStr)

A string literal. Spec §12.2 E5.

§

Var(VarId)

A resolved variable reference. Spec §12.2 E6.

§

Prop

A property access (expr.prop). Spec §12.2 E7.

Fields

§target: Box<Expr>

Expression evaluating to a node, relationship, or map.

§prop: SmolStr

Property key.

§

Index

A subscript / index access (expr[index]). Spec §12.2 E8.

Fields

§target: Box<Expr>

Expression evaluating to a list or map.

§index: Box<Expr>

Index expression (integer for lists, string for maps).

§

Slice

A list slice (expr[start..end]). cy-7s6.1 (spec §12.2 E8, extended for openCypher list slicing).

Either bound may be None to represent the elided form: xs[..j] -> start = None, end = Some(j); xs[i..] -> start = Some(i), end = None. Negative indices carry their from-end meaning at evaluation time; the plan does not normalise them.

Fields

§target: Box<Expr>

Expression evaluating to a list.

§start: Option<Box<Expr>>

Optional lower bound (inclusive, elidable).

§end: Option<Box<Expr>>

Optional upper bound (exclusive, elidable).

§

List(Vec<Expr>)

A list literal ([e1, e2, ...]). Spec §12.2 E9.

§

Map(Vec<(SmolStr, Expr)>)

A map literal ({k1: e1, k2: e2}). Spec §12.2 E10.

§

Call

A resolved function call. Spec §12.2 E11.

func is the canonical lower-case function name as resolved by the built-in catalog (spec §8.3) or the consumer-provided catalog.

Fields

§func: SmolStr

Resolved function name.

§args: Vec<Expr>

Argument expressions.

§

BinOp

A binary operator application. Spec §12.2 E12.

Fields

§op: BinOp

Operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

UnaryOp

A unary operator application. Spec §12.2 E13.

Fields

§op: UnaryOp

Operator.

§operand: Box<Expr>

Operand.

§

Case

A CASE expression. Spec §12.2 E14.

scrutinee is present for simple CASE x WHEN … form; absent for searched CASE WHEN cond THEN … form.

Fields

§scrutinee: Option<Box<Expr>>

Optional scrutinee for simple CASE.

§arms: Vec<(Expr, Expr)>

(when, then) arms, tested in order.

§otherwise: Option<Box<Expr>>

ELSE expression, or Null when absent.

§

IsNull

x IS NULL / x IS NOT NULL. Spec §12.2 E15.

Fields

§operand: Box<Expr>

Operand.

§negated: bool

true for IS NOT NULL.

§

InList

x IN list membership test. Spec §12.2 E16.

Fields

§operand: Box<Expr>

Value to test.

§list: Box<Expr>

List to test membership in.

§

ListPredicate

A list predicate — ANY|ALL|NONE|SINGLE(v IN xs [WHERE p(v)]) (cy-8x5). Result type is Bool.

Mirrors the HIR shape: the binder var is scoped to the predicate sub-expression only; the iterable evaluates in the enclosing row scope. predicate is None for the bare form (ANY(x IN xs) — true iff xs is non-empty).

Fields

§kind: ListPredKind

Which of the four list predicates.

§var: VarId

Plan-scoped id of the iteration variable.

§iterable: Box<Expr>

Source list expression.

§predicate: Option<Box<Expr>>

Optional Bool predicate; None for the bare form.

§

Param

A query parameter reference. Spec §12.4.

The consumer binds parameter values at execution time. The plan does not carry values. ty is deferred to bead cy-foy (HIR→Plan lowering) because type inference runs in cyrs-sema, which is not a dependency of this crate.

Fields

§name: SmolStr

Parameter name as written in the query ($name or {name}).

§

Exists

A pattern-predicate existential check — EXISTS(<pattern>) in expression position (cy-lve, spec §6.1 / §19 row “Pattern predicates in expressions”).

Evaluates to true iff the embedded read sub-plan would yield at least one row when evaluated against the enclosing row’s variable bindings. Result type is Bool.

The pattern sub-tree is embedded directly (like ReadOp::OptionalJoin) because a pattern predicate is always a fresh sub-plan at the point it appears in the enclosing expression — its shape cannot be shared with other operators in the outer DAG. Variables that appear both inside the pattern and in the outer row remain unified via VarId (plan-scoped), consistent with the rest of the plan’s variable model.

Fields

§pattern: Box<ReadOp>

Embedded read-plan sub-tree; existence of ≥1 emitted row makes this expression true, otherwise false.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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<'de> Deserialize<'de> for Expr

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. 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 (const: unstable) · 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 Serialize for Expr

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Expr

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 UnsafeUnpin 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,