Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
    Star {
        qualifier: Slice,
    },
    Column {
        name: Slice,
    },
    Literal {
        kind: LiteralKind,
        text: StrRef,
    },
    Unary {
        op: UnaryOp,
        operand: ExprRef,
    },
    Binary {
        op: BinaryOp,
        left: ExprRef,
        right: ExprRef,
    },
    Function {
        name: Slice,
        args: Slice,
        distinct: bool,
    },
    Cast {
        operand: ExprRef,
        ty: StrRef,
        try_cast: bool,
    },
    Case {
        operand: ExprRef,
        arms: Slice,
        otherwise: ExprRef,
    },
    Between {
        operand: ExprRef,
        low: ExprRef,
        high: ExprRef,
        negated: bool,
    },
    In {
        operand: ExprRef,
        list: Slice,
        negated: bool,
    },
    Row {
        items: Slice,
    },
    Subquery {
        query: QueryRef,
    },
}
Expand description

One expression.

Twenty four bytes, which is the widest variant rounded up. The precedence chain in the grammar does not survive into here: twenty levels of X <- Y Tail* become one Expr::Binary tree, because the levels exist to make the grammar unambiguous and mean nothing afterwards.

Variants§

§

Star

*, or t.* with a qualifier.

Fields

§qualifier: Slice

The qualifier, as a run of StrRef, empty for a bare star.

§

Column

A column reference, qualified or not.

Fields

§name: Slice

The name, as a run of StrRef, outermost first, so s.t.a is three parts.

§

Literal

A literal, kept as the text that was written.

Fields

§kind: LiteralKind

Which kind.

§text: StrRef

The text, with quotes stripped and escapes resolved for a string, NONE for a keyword literal like NULL where the kind already says everything.

§

Unary

A prefix or postfix operator.

Fields

§op: UnaryOp

Which operator.

§operand: ExprRef

What it applies to.

§

Binary

An infix operator.

Fields

§op: BinaryOp

Which operator.

§left: ExprRef

The left operand.

§right: ExprRef

The right operand.

§

Function

A function call.

Fields

§name: Slice

The name, as a run of StrRef, so main.count is two parts.

§args: Slice

The arguments, as a run of ExprRef.

§distinct: bool

Whether the call said DISTINCT.

§

Cast

CAST(x AS t) or TRY_CAST(x AS t).

Fields

§operand: ExprRef

What is being cast.

§ty: StrRef

The target type, as the text it was written with. Parsing it is rudb-common’s job and doing it here would put the type system in the parser.

§try_cast: bool

Whether a failure yields null rather than an error.

§

Case

CASE, searched or simple.

Fields

§operand: ExprRef

The operand of a simple CASE x WHEN, or NONE for a searched one.

§arms: Slice

The arms, as a run of CaseArm.

§otherwise: ExprRef

The ELSE, or NONE.

§

Between

x BETWEEN a AND b.

Fields

§operand: ExprRef

What is being tested.

§low: ExprRef

The lower bound.

§high: ExprRef

The upper bound.

§negated: bool

Whether it was written NOT BETWEEN.

§

In

x IN (a, b, c).

Fields

§operand: ExprRef

What is being tested.

§list: Slice

The list, as a run of ExprRef.

§negated: bool

Whether it was written NOT IN.

§

Row

A parenthesised list of more than one expression, which is a row value.

Fields

§items: Slice

The items, as a run of ExprRef.

§

Subquery

A scalar subquery, (SELECT ...) where an expression is expected.

Fields

§query: QueryRef

The query.

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 Copy for Expr

Source§

impl Debug for Expr

Source§

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

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

impl Eq for Expr

Source§

impl PartialEq for Expr

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.