Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 28 variants Int(u64), Float(f64), Str(String), Bool(bool), Unit, Name(Ident), SelfValue, SelfType, Paren(Box<Expr>), List(Vec<Expr>), Map(Vec<(Expr, Expr)>), StructLit { path: Path, type_args: Vec<Ty>, fields: Vec<FieldInit>, }, Field { base: Box<Expr>, name: Ident, }, TypeArgs { base: Box<Expr>, args: Vec<Ty>, }, Call { callee: Box<Expr>, args: Vec<Arg>, }, Index { base: Box<Expr>, index: Box<Expr>, }, Slice { base: Box<Expr>, start: Option<Box<Expr>>, end: Option<Box<Expr>>, inclusive: bool, }, Try(Box<Expr>), Unary { op: UnaryOp, operand: Box<Expr>, }, Binary { op: BinaryOp, lhs: Box<Expr>, rhs: Box<Expr>, }, Closure { params: Vec<ClosureParam>, ret: Option<Ty>, body: Box<Expr>, }, Block(Block), If { cond: Box<Expr>, then: Block, otherwise: Option<Box<Expr>>, }, Match { mode: Mode, scrutinee: Box<Expr>, arms: Vec<Arm>, }, Return(Option<Box<Expr>>), Break, Continue, Error,
}
Expand description

The forms of expressions.

Variants§

§

Int(u64)

An integer literal.

§

Float(f64)

A float literal.

§

Str(String)

A string literal.

§

Bool(bool)

true or false.

§

Unit

()

§

Name(Ident)

A name.

§

SelfValue

self

§

SelfType

Self

§

Paren(Box<Expr>)

(e)

§

List(Vec<Expr>)

[a, b]

§

Map(Vec<(Expr, Expr)>)

["a": 1], [:]

§

StructLit

Path.<T> { field: value, shorthand }

Fields

§path: Path

The type name.

§type_args: Vec<Ty>

Explicit type arguments .<T>.

§fields: Vec<FieldInit>

The fields.

§

Field

base.name

Fields

§base: Box<Expr>

The left side.

§name: Ident

The name after the dot.

§

TypeArgs

base.<T, U>

Fields

§base: Box<Expr>

The left side.

§args: Vec<Ty>

The type arguments.

§

Call

callee(args)

Fields

§callee: Box<Expr>

What is called.

§args: Vec<Arg>

The arguments.

§

Index

base[index]

Fields

§base: Box<Expr>

The collection.

§index: Box<Expr>

The index.

§

Slice

base[a..b] and the other slice forms.

Fields

§base: Box<Expr>

The collection.

§start: Option<Box<Expr>>

The start, if written.

§end: Option<Box<Expr>>

The end, if written.

§inclusive: bool

..=

§

Try(Box<Expr>)

e?

§

Unary

-e, !e, ~e

Fields

§op: UnaryOp

The operator.

§operand: Box<Expr>

The operand.

§

Binary

a op b

Fields

§op: BinaryOp

The operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

Closure

|x, y: Int| body or |x| -> T { body }.

Fields

§params: Vec<ClosureParam>

The parameters.

§ret: Option<Ty>

The written result type.

§body: Box<Expr>

The body.

§

Block(Block)

{ ... } as the body of a closure or a match arm.

§

If

if cond { } else ...

Fields

§cond: Box<Expr>

The condition.

§then: Block

The first branch.

§otherwise: Option<Box<Expr>>

else followed by a block or another if.

§

Match

match mode? scrutinee { arms }

Fields

§mode: Mode

The mode marker.

§scrutinee: Box<Expr>

The matched value.

§arms: Vec<Arm>

The arms.

§

Return(Option<Box<Expr>>)

return e?

§

Break

break

§

Continue

continue

§

Error

Something that could not be parsed; a diagnostic was reported.

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> Self

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
Source§

impl PartialEq for ExprKind

Source§

fn eq(&self, other: &Self) -> 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 ExprKind

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 = !

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.