Enum syn::ExprKind [−][src]
pub enum ExprKind { Box(Box<Expr>), InPlace(Box<Expr>, Box<Expr>), Array(Vec<Expr>), Call(Box<Expr>, Vec<Expr>), MethodCall(Ident, Vec<Ty>, Vec<Expr>), Tup(Vec<Expr>), Binary(BinOp, Box<Expr>, Box<Expr>), Unary(UnOp, Box<Expr>), Lit(Lit), Cast(Box<Expr>, Box<Ty>), Type(Box<Expr>, Box<Ty>), If(Box<Expr>, Block, Option<Box<Expr>>), IfLet(Box<Pat>, Box<Expr>, Block, Option<Box<Expr>>), While(Box<Expr>, Block, Option<Ident>), WhileLet(Box<Pat>, Box<Expr>, Block, Option<Ident>), ForLoop(Box<Pat>, Box<Expr>, Block, Option<Ident>), Loop(Block, Option<Ident>), Match(Box<Expr>, Vec<Arm>), Closure(CaptureBy, Box<FnDecl>, Box<Expr>), Block(Unsafety, Block), Assign(Box<Expr>, Box<Expr>), AssignOp(BinOp, Box<Expr>, Box<Expr>), Field(Box<Expr>, Ident), TupField(Box<Expr>, usize), Index(Box<Expr>, Box<Expr>), Range(Option<Box<Expr>>, Option<Box<Expr>>, RangeLimits), Path(Option<QSelf>, Path), AddrOf(Mutability, Box<Expr>), Break(Option<Ident>, Option<Box<Expr>>), Continue(Option<Ident>), Ret(Option<Box<Expr>>), Mac(Mac), Struct(Path, Vec<FieldValue>, Option<Box<Expr>>), Repeat(Box<Expr>, Box<Expr>), Paren(Box<Expr>), Try(Box<Expr>), }
Variants
Box(Box<Expr>)
A box x
expression.
InPlace(Box<Expr>, Box<Expr>)
First expr is the place; second expr is the value.
E.g. 'plae <- val'.
Array(Vec<Expr>)
An array, e.g. [a, b, c, d]
.
Call(Box<Expr>, Vec<Expr>)
A function call.
The first field resolves to the function itself, and the second field is the list of arguments
MethodCall(Ident, Vec<Ty>, Vec<Expr>)
A method call (x.foo::<Bar, Baz>(a, b, c, d)
)
The Ident
is the identifier for the method name.
The vector of Ty
s are the ascripted type parameters for the method
(within the angle brackets).
The first element of the vector of Expr
s 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(foo, [Bar, Baz], [x, a, b, c, d])
.
Tup(Vec<Expr>)
A tuple, e.g. (a, b, c, d)
.
Binary(BinOp, Box<Expr>, Box<Expr>)
A binary operation, e.g. a + b
, a * b
.
Unary(UnOp, Box<Expr>)
A unary operation, e.g. !x
, *x
.
Lit(Lit)
A literal, e.g. 1
, "foo"
.
Cast(Box<Expr>, Box<Ty>)
A cast, e.g. foo as f64
.
Type(Box<Expr>, Box<Ty>)
A type ascription, e.g. foo: f64
.
If(Box<Expr>, Block, Option<Box<Expr>>)
An if
block, with an optional else block
E.g., if expr { block } else { expr }
IfLet(Box<Pat>, Box<Expr>, Block, Option<Box<Expr>>)
An if let
expression with an optional else block
E.g., if let pat = expr { block } else { expr }
This is desugared to a match
expression.
While(Box<Expr>, Block, Option<Ident>)
A while loop, with an optional label
E.g., 'label: while expr { block }
WhileLet(Box<Pat>, Box<Expr>, Block, Option<Ident>)
A while-let loop, with an optional label.
E.g., 'label: while let pat = expr { block }
This is desugared to a combination of loop
and match
expressions.
ForLoop(Box<Pat>, Box<Expr>, Block, Option<Ident>)
A for loop, with an optional label.
E.g., 'label: for pat in expr { block }
This is desugared to a combination of loop
and match
expressions.
Loop(Block, Option<Ident>)
Conditionless loop with an optional label.
E.g. 'label: loop { block }
Match(Box<Expr>, Vec<Arm>)
A match
block.
Closure(CaptureBy, Box<FnDecl>, Box<Expr>)
A closure (for example, move |a, b, c| a + b + c
)
Block(Unsafety, Block)
A block ({ ... }
or unsafe { ... }
)
Assign(Box<Expr>, Box<Expr>)
An assignment (a = foo()
)
AssignOp(BinOp, Box<Expr>, Box<Expr>)
An assignment with an operator
For example, a += 1
.
Field(Box<Expr>, Ident)
Access of a named struct field (obj.foo
)
TupField(Box<Expr>, usize)
Access of an unnamed field of a struct or tuple-struct
For example, foo.0
.
Index(Box<Expr>, Box<Expr>)
An indexing operation (foo[2]
)
Range(Option<Box<Expr>>, Option<Box<Expr>>, RangeLimits)
A range (1..2
, 1..
, ..2
, 1...2
, 1...
, ...2
)
Path(Option<QSelf>, Path)
Variable reference, possibly containing ::
and/or type
parameters, e.g. foo::bar::
Optionally "qualified",
E.g. <Vec<T> as SomeTrait>::SomeType
.
AddrOf(Mutability, Box<Expr>)
A referencing operation (&a
or &mut a
)
Break(Option<Ident>, Option<Box<Expr>>)
A break
, with an optional label to break, and an optional expression
Continue(Option<Ident>)
A continue
, with an optional label
Ret(Option<Box<Expr>>)
A return
, with an optional value to be returned
Mac(Mac)
A macro invocation; pre-expansion
Struct(Path, Vec<FieldValue>, Option<Box<Expr>>)
A struct literal expression.
For example, Foo {x: 1, y: 2}
, or
Foo {x: 1, .. base}
, where base
is the Option<Expr>
.
Repeat(Box<Expr>, Box<Expr>)
An array literal constructed from one repeated element.
For example, [1; 5]
. The first expression is the element
to be repeated; the second is the number of times to repeat it.
Paren(Box<Expr>)
No-op: used solely so we can pretty-print faithfully
Try(Box<Expr>)
expr?
Trait Implementations
impl From<ExprKind> for Expr
[src]
impl From<ExprKind> for Expr
impl Debug for ExprKind
[src]
impl Debug for ExprKind
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for ExprKind
[src]
impl Clone for ExprKind
fn clone(&self) -> ExprKind
[src]
fn clone(&self) -> ExprKind
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Eq for ExprKind
[src]
impl Eq for ExprKind
impl PartialEq for ExprKind
[src]
impl PartialEq for ExprKind
fn eq(&self, other: &ExprKind) -> bool
[src]
fn eq(&self, other: &ExprKind) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &ExprKind) -> bool
[src]
fn ne(&self, other: &ExprKind) -> bool
This method tests for !=
.
impl Hash for ExprKind
[src]
impl Hash for ExprKind