Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 26 variants Int(i64), Float(f64), Bool(bool), Duration(i64), Str(Vec<StrPart>), Unit, Ident(String), ArrayLit(Vec<Expr>), Field { base: Box<Expr>, name: Ident, }, Call { callee: Box<Expr>, generics: Vec<Type>, args: Vec<Arg>, trailing: Option<Box<Expr>>, }, Unary { op: UnaryOp, operand: Box<Expr>, }, Binary { op: BinaryOp, lhs: Box<Expr>, rhs: Box<Expr>, }, Assign { op: Option<BinaryOp>, target: Box<Expr>, value: Box<Expr>, }, Try(Box<Expr>), Await(Box<Expr>), Block(Block), If { condition: Box<Expr>, then_branch: Block, else_branch: Option<Box<Expr>>, }, Match { scrutinee: Box<Expr>, arms: Vec<MatchArm>, }, For { binding: Ident, iterable: Box<Expr>, body: Block, }, While { condition: Box<Expr>, body: Block, }, Return(Option<Box<Expr>>), Break(Option<Box<Expr>>), Continue, Lambda { is_async: bool, params: Vec<Param>, body: Block, }, Scope { name: Ident, body: Block, }, Range { start: Box<Expr>, end: Box<Expr>, inclusive_end: bool, },
}

Variants§

§

Int(i64)

§

Float(f64)

§

Bool(bool)

§

Duration(i64)

§

Str(Vec<StrPart>)

A string literal with its interpolated expressions already parsed.

§

Unit

()

§

Ident(String)

A bare name.

§

ArrayLit(Vec<Expr>)

[1, 2] produces an immutable Array.

§

Field

console.println, LogLevel.Debug, self.status

Fields

§base: Box<Expr>
§name: Ident
§

Call

f(a, b: c); also struct initialization via synthesized labeled calls.

Fields

§callee: Box<Expr>
§generics: Vec<Type>
§args: Vec<Arg>
§trailing: Option<Box<Expr>>

clock.timeout(500ms) { ... } and tasks.spawn { ... }.

§

Unary

Fields

§operand: Box<Expr>
§

Binary

Fields

§lhs: Box<Expr>
§rhs: Box<Expr>
§

Assign

place = value, place += value

Fields

§target: Box<Expr>
§value: Box<Expr>
§

Try(Box<Expr>)

expr? returns the error from the current function.

§

Await(Box<Expr>)

§

Block(Block)

§

If

Fields

§condition: Box<Expr>
§then_branch: Block
§else_branch: Option<Box<Expr>>
§

Match

match must cover every enum case.

Fields

§scrutinee: Box<Expr>
§

For

A loop is an expression. It evaluates to Unit, because it can reach its end without breaking and there is nothing at that end to produce but Unit.

Fields

§binding: Ident
§iterable: Box<Expr>
§body: Block
§

While

Fields

§condition: Box<Expr>
§body: Block
§

Return(Option<Box<Expr>>)

§

Break(Option<Box<Expr>>)

break / break expr. Exits the nearest enclosing loop, which is Unit however it leaves: expr is evaluated for its effects and its value discarded. Resolve rejects a break outside a loop.

§

Continue

continue. Skips to the next iteration of the nearest enclosing loop. Resolve rejects this outside a loop.

§

Lambda

fn(x) { ... } / async fn(x) { ... }

Fields

§is_async: bool
§params: Vec<Param>
§body: Block
§

Scope

scope tasks { ... }

Fields

§name: Ident
§body: Block
§

Range

0..<attempts and 0..n

Fields

§start: Box<Expr>
§end: Box<Expr>
§inclusive_end: bool

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> ExprKind

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 ExprKind

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.