Expr

Enum Expr 

Source
pub enum Expr<'a> {
Show 19 variants Literal(Literal), Identifier(Symbol), BinaryOp { op: BinaryOpKind, left: &'a Expr<'a>, right: &'a Expr<'a>, }, Call { function: Symbol, args: Vec<&'a Expr<'a>>, }, Index { collection: &'a Expr<'a>, index: &'a Expr<'a>, }, Slice { collection: &'a Expr<'a>, start: &'a Expr<'a>, end: &'a Expr<'a>, }, Copy { expr: &'a Expr<'a>, }, Length { collection: &'a Expr<'a>, }, Contains { collection: &'a Expr<'a>, value: &'a Expr<'a>, }, Union { left: &'a Expr<'a>, right: &'a Expr<'a>, }, Intersection { left: &'a Expr<'a>, right: &'a Expr<'a>, }, ManifestOf { zone: &'a Expr<'a>, }, ChunkAt { index: &'a Expr<'a>, zone: &'a Expr<'a>, }, List(Vec<&'a Expr<'a>>), Tuple(Vec<&'a Expr<'a>>), Range { start: &'a Expr<'a>, end: &'a Expr<'a>, }, FieldAccess { object: &'a Expr<'a>, field: Symbol, }, New { type_name: Symbol, type_args: Vec<Symbol>, init_fields: Vec<(Symbol, &'a Expr<'a>)>, }, NewVariant { enum_name: Symbol, variant: Symbol, fields: Vec<(Symbol, &'a Expr<'a>)>, },
}
Expand description

Shared expression type for pure computations (LOGOS §15.0.0).

Expr is used by both LogicExpr (as terms) and Stmt (as values). These are pure computations without side effects.

Variants§

§

Literal(Literal)

Literal value: 42, “hello”, true, nothing

§

Identifier(Symbol)

Variable reference: x

§

BinaryOp

Binary operation: x plus y

Fields

§left: &'a Expr<'a>
§right: &'a Expr<'a>
§

Call

Function call as expression: f(x, y)

Fields

§function: Symbol
§args: Vec<&'a Expr<'a>>
§

Index

Dynamic index access: items at i (1-indexed).

Fields

§collection: &'a Expr<'a>
§index: &'a Expr<'a>
§

Slice

Dynamic slice access: items 1 through mid (1-indexed, inclusive).

Fields

§collection: &'a Expr<'a>
§start: &'a Expr<'a>
§end: &'a Expr<'a>
§

Copy

Copy expression: copy of slice → slice.to_vec().

Fields

§expr: &'a Expr<'a>
§

Length

Length expression: length of items → items.len().

Fields

§collection: &'a Expr<'a>
§

Contains

Set contains: set contains x or x in set

Fields

§collection: &'a Expr<'a>
§value: &'a Expr<'a>
§

Union

Set union: a union b

Fields

§left: &'a Expr<'a>
§right: &'a Expr<'a>
§

Intersection

Set intersection: a intersection b

Fields

§left: &'a Expr<'a>
§right: &'a Expr<'a>
§

ManifestOf

Get manifest of a zone. the manifest of Zone → FileSipper::from_zone(&zone).manifest()

Fields

§zone: &'a Expr<'a>
§

ChunkAt

Get chunk at index from a zone. the chunk at N in Zone → FileSipper::from_zone(&zone).get_chunk(N)

Fields

§index: &'a Expr<'a>
§zone: &'a Expr<'a>
§

List(Vec<&'a Expr<'a>>)

List literal: [1, 2, 3]

§

Tuple(Vec<&'a Expr<'a>>)

Tuple literal: (1, “hello”, true)

§

Range

Range: 1 to 10 (inclusive)

Fields

§start: &'a Expr<'a>
§end: &'a Expr<'a>
§

FieldAccess

Field access: p's x or the x of p.

Fields

§object: &'a Expr<'a>
§field: Symbol
§

New

Constructor: a new Point or a new Point with x 10 and y 20. Supports generics: a new Box of Int

Fields

§type_name: Symbol
§type_args: Vec<Symbol>
§init_fields: Vec<(Symbol, &'a Expr<'a>)>
§

NewVariant

Enum variant constructor: a new Circle with radius 10.

Fields

§enum_name: Symbol
§variant: Symbol
§fields: Vec<(Symbol, &'a Expr<'a>)>

Trait Implementations§

Source§

impl<'a> Debug for Expr<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Expr<'a>

§

impl<'a> RefUnwindSafe for Expr<'a>

§

impl<'a> Send for Expr<'a>

§

impl<'a> Sync for Expr<'a>

§

impl<'a> Unpin for Expr<'a>

§

impl<'a> UnwindSafe for Expr<'a>

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> 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, 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