[][src]Enum syntax::ast::ExprKind

pub enum ExprKind {
    Box(P<Expr>),
    ObsoleteInPlace(P<Expr>, P<Expr>),
    Array(Vec<P<Expr>>),
    Call(P<Expr>, Vec<P<Expr>>),
    MethodCall(PathSegmentVec<P<Expr>>),
    Tup(Vec<P<Expr>>),
    Binary(BinOpP<Expr>, P<Expr>),
    Unary(UnOpP<Expr>),
    Lit(P<Lit>),
    Cast(P<Expr>, P<Ty>),
    Type(P<Expr>, P<Ty>),
    If(P<Expr>, P<Block>, Option<P<Expr>>),
    IfLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<P<Expr>>),
    While(P<Expr>, P<Block>, Option<Label>),
    WhileLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<Label>),
    ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>),
    Loop(P<Block>, Option<Label>),
    Match(P<Expr>, Vec<Arm>),
    Closure(CaptureByIsAsyncMovabilityP<FnDecl>, P<Expr>, Span),
    Block(P<Block>, Option<Label>),
    Async(CaptureByNodeIdP<Block>),
    TryBlock(P<Block>),
    Assign(P<Expr>, P<Expr>),
    AssignOp(BinOpP<Expr>, P<Expr>),
    Field(P<Expr>, Ident),
    Index(P<Expr>, P<Expr>),
    Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
    Path(Option<QSelf>, Path),
    AddrOf(MutabilityP<Expr>),
    Break(Option<Label>, Option<P<Expr>>),
    Continue(Option<Label>),
    Ret(Option<P<Expr>>),
    InlineAsm(P<InlineAsm>),
    Mac(Mac),
    Struct(PathVec<Field>, Option<P<Expr>>),
    Repeat(P<Expr>, AnonConst),
    Paren(P<Expr>),
    Try(P<Expr>),
    Yield(Option<P<Expr>>),
}

Variants

A box x expression.

First expr is the place; second expr is the value.

An array ([a, b, c, d])

A function call

The first field resolves to the function itself, and the second field is the list of arguments. This also represents calling the constructor of tuple-like ADTs such as tuple structs and enum variants.

A method call (x.foo::<'static, Bar, Baz>(a, b, c, d))

The PathSegment represents the method name and its generic arguments (within the angle brackets). The first element of the vector of Exprs is the expression that evaluates to the object on which the method is being called on (the receiver), and the remaining elements are the rest of the arguments. Thus, x.foo::<Bar, Baz>(a, b, c, d) is represented as ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d]).

A tuple ((a, b, c ,d))

A binary operation (For example: a + b, a * b)

A unary operation (For example: !x, *x)

A literal (For example: 1, "foo")

A cast (foo as f64)

An if block, with an optional else block

if expr { block } else { expr }

An if let expression with an optional else block

if let pat = expr { block } else { expr }

This is desugared to a match expression.

A while loop, with an optional label

'label: while expr { block }

A while-let loop, with an optional label

'label: while let pat = expr { block }

This is desugared to a combination of loop and match expressions.

A for loop, with an optional label

'label: for pat in expr { block }

This is desugared to a combination of loop and match expressions.

Conditionless loop (can be exited with break, continue, or return)

'label: loop { block }

A match block.

A closure (for example, move |a, b, c| a + b + c)

The final span is the span of the argument block |...|

A block ('label: { ... })

An async block (async move { ... })

The NodeId is the NodeId for the closure that results from desugaring an async block, just like the NodeId field in the IsAsync enum. This is necessary in order to create a def for the closure which can be used as a parent of any child defs. Defs created during lowering cannot be made the parent of any other preexisting defs.

A try block (try { ... })

An assignment (a = foo())

An assignment with an operator

For example, a += 1.

Access of a named (obj.foo) or unnamed (obj.0) struct field

An indexing operation (foo[2])

A range (1..2, 1.., ..2, 1...2, 1..., ...2)

Variable reference, possibly containing :: and/or type parameters, e.g. foo::bar::.

Optionally "qualified", E.g. <Vec<T> as SomeTrait>::SomeType.

A referencing operation (&a or &mut a)

A break, with an optional label to break, and an optional expression

A continue, with an optional label

A return, with an optional value to be returned

Output of the asm!() macro

A macro invocation; pre-expansion

A struct literal expression.

For example, Foo {x: 1, y: 2}, or Foo {x: 1, .. base}, where base is the Option<Expr>.

An array literal constructed from one repeated element.

For example, [1; 5]. The expression is the element to be repeated; the constant is the number of times to repeat it.

No-op: used solely so we can pretty-print faithfully

expr?

A yield, with an optional value to be yielded

Trait Implementations

impl Clone for ExprKind
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for ExprKind
[src]

Formats the value using the given formatter. Read more

impl Encodable for ExprKind
[src]

impl Decodable for ExprKind
[src]

Auto Trait Implementations

impl !Send for ExprKind

impl !Sync for ExprKind

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<E> SpecializationError for E
[src]

Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S is the encoder/decoder state type, T is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more

impl<T> Erased for T
[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Erased for T