Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 42 variants Int(i64), Float(f64), Bool(bool), Str(String), FStr(Vec<FStrPart>), Bytes(Vec<u8>), None, Unit, Ident(String), ModulePath(Vec<String>), SomeExpr(Box<Expr>), OkExpr(Box<Expr>), ErrExpr(Box<Expr>), List(Vec<ListEntry>), Dict(Vec<DictEntry>), Tuple(Vec<Expr>), ListComp { expr: Box<Expr>, pattern: Pattern, iter: Box<Expr>, cond: Option<Box<Expr>>, }, DictComp { key: Box<Expr>, value: Box<Expr>, pattern: Pattern, iter: Box<Expr>, cond: Option<Box<Expr>>, }, BinOp { left: Box<Expr>, op: BinOp, right: Box<Expr>, }, UnaryOp { op: UnaryOp, expr: Box<Expr>, }, Try(Box<Expr>), PipeOp { left: Box<Expr>, right: Box<Expr>, }, FieldAccess { expr: Box<Expr>, field: String, }, Index { expr: Box<Expr>, index: Box<Expr>, }, Slice { expr: Box<Expr>, start: Option<Box<Expr>>, end: Option<Box<Expr>>, inclusive: bool, }, MethodCall { expr: Box<Expr>, method: String, args: Vec<CallArg>, }, Call { func: Box<Expr>, args: Vec<CallArg>, }, Lambda { params: Vec<String>, body: Box<Expr>, }, If { cond: Box<Expr>, then_body: Vec<Stmt>, else_body: Option<Vec<Stmt>>, }, IfLet { pattern: Pattern, expr: Box<Expr>, then_body: Vec<Stmt>, else_body: Option<Vec<Stmt>>, }, Match { expr: Box<Expr>, arms: Vec<MatchArm>, }, Block(Vec<Stmt>), LoopExpr(Vec<Stmt>), TryCatch { body: Vec<Stmt>, var: String, handler: Vec<Stmt>, }, StructConstruct { name: String, fields: Vec<(String, Expr)>, spread: Option<Box<Expr>>, }, EnumVariant { enum_name: String, variant: String, }, EnumVariantCall { enum_name: String, variant: String, args: Vec<Expr>, }, Range { start: Box<Expr>, end: Box<Expr>, inclusive: bool, }, AsyncBlock(Vec<Stmt>), SpawnExpr(Box<Expr>), AwaitExpr(Box<Expr>), SelectExpr(Vec<SelectBranch>),
}

Variants§

§

Int(i64)

§

Float(f64)

§

Bool(bool)

§

Str(String)

§

FStr(Vec<FStrPart>)

f-string: list of parts (literal strings and expressions)

§

Bytes(Vec<u8>)

§

None

§

Unit

§

Ident(String)

§

ModulePath(Vec<String>)

module::path::name — module path access

§

SomeExpr(Box<Expr>)

Some(expr)

§

OkExpr(Box<Expr>)

Ok(expr)

§

ErrExpr(Box<Expr>)

Err(expr)

§

List(Vec<ListEntry>)

[a, b, ...c] with optional spread entries

§

Dict(Vec<DictEntry>)

#{ "key": val, ... } with optional spread entries

§

Tuple(Vec<Expr>)

(a, b, c)

§

ListComp

[expr for pattern in iter if cond]

Fields

§expr: Box<Expr>
§pattern: Pattern
§iter: Box<Expr>
§cond: Option<Box<Expr>>
§

DictComp

#{ key: val for pattern in iter if cond }

Fields

§key: Box<Expr>
§value: Box<Expr>
§pattern: Pattern
§iter: Box<Expr>
§cond: Option<Box<Expr>>
§

BinOp

Fields

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

UnaryOp

Fields

§expr: Box<Expr>
§

Try(Box<Expr>)

expr?

§

PipeOp

a |> b

Fields

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

FieldAccess

expr.field

Fields

§expr: Box<Expr>
§field: String
§

Index

expr[index]

Fields

§expr: Box<Expr>
§index: Box<Expr>
§

Slice

expr[start..end], expr[..end], expr[start..]

Fields

§expr: Box<Expr>
§start: Option<Box<Expr>>
§inclusive: bool
§

MethodCall

expr.method(args)

Fields

§expr: Box<Expr>
§method: String
§args: Vec<CallArg>
§

Call

func(args)

Fields

§func: Box<Expr>
§args: Vec<CallArg>
§

Lambda

|params| body

Fields

§params: Vec<String>
§body: Box<Expr>
§

If

if cond { then } [else { else_ }]

Fields

§cond: Box<Expr>
§then_body: Vec<Stmt>
§else_body: Option<Vec<Stmt>>
§

IfLet

if let pattern = expr { then } [else { else_ }]

Fields

§pattern: Pattern
§expr: Box<Expr>
§then_body: Vec<Stmt>
§else_body: Option<Vec<Stmt>>
§

Match

match expr { arms }

Fields

§expr: Box<Expr>
§

Block(Vec<Stmt>)

{ stmts }

§

LoopExpr(Vec<Stmt>)

loop { body } as expression (returns break value)

§

TryCatch

try { body } catch ident { handler }

Fields

§body: Vec<Stmt>
§handler: Vec<Stmt>
§

StructConstruct

Fields

§name: String
§fields: Vec<(String, Expr)>
§spread: Option<Box<Expr>>
§

EnumVariant

Fields

§enum_name: String
§variant: String
§

EnumVariantCall

Fields

§enum_name: String
§variant: String
§args: Vec<Expr>
§

Range

Fields

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

AsyncBlock(Vec<Stmt>)

async { body } — structured concurrency scope

§

SpawnExpr(Box<Expr>)

spawn expr — launch a child task, returns Task handle

§

AwaitExpr(Box<Expr>)

expr.await — wait for a task/future result

§

SelectExpr(Vec<SelectBranch>)

select { branch => expr, ... } — race multiple async expressions

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> ExprKind

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