[−][src]Enum syntax::ast::ExprKind
Variants
Box(P<Expr>)
A box x
expression.
ObsoleteInPlace(P<Expr>, P<Expr>)
First expr is the place; second expr is the value.
Array(Vec<P<Expr>>)
An array ([a, b, c, d]
)
Call(P<Expr>, Vec<P<Expr>>)
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.
MethodCall(PathSegment, Vec<P<Expr>>)
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 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(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d])
.
Tup(Vec<P<Expr>>)
A tuple ((a, b, c ,d)
)
Binary(BinOp, P<Expr>, P<Expr>)
A binary operation (For example: a + b
, a * b
)
Unary(UnOp, P<Expr>)
A unary operation (For example: !x
, *x
)
Lit(P<Lit>)
A literal (For example: 1
, "foo"
)
Cast(P<Expr>, P<Ty>)
A cast (foo as f64
)
Type(P<Expr>, P<Ty>)
If(P<Expr>, P<Block>, Option<P<Expr>>)
An if
block, with an optional else block
if expr { block } else { expr }
IfLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<P<Expr>>)
An if let
expression with an optional else block
if let pat = expr { block } else { expr }
This is desugared to a match
expression.
While(P<Expr>, P<Block>, Option<Label>)
A while loop, with an optional label
'label: while expr { block }
WhileLet(Vec<P<Pat>>, P<Expr>, P<Block>, Option<Label>)
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.
ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>)
A for loop, with an optional label
'label: for pat in expr { block }
This is desugared to a combination of loop
and match
expressions.
Loop(P<Block>, Option<Label>)
Conditionless loop (can be exited with break, continue, or return)
'label: loop { block }
Match(P<Expr>, Vec<Arm>)
A match
block.
Closure(CaptureBy, IsAsync, Movability, P<FnDecl>, P<Expr>, Span)
A closure (for example, move |a, b, c| a + b + c
)
The final span is the span of the argument block |...|
Block(P<Block>, Option<Label>)
A block ('label: { ... }
)
Async(CaptureBy, NodeId, P<Block>)
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.
TryBlock(P<Block>)
A try block (try { ... }
)
Assign(P<Expr>, P<Expr>)
An assignment (a = foo()
)
AssignOp(BinOp, P<Expr>, P<Expr>)
An assignment with an operator
For example, a += 1
.
Field(P<Expr>, Ident)
Access of a named (obj.foo
) or unnamed (obj.0
) struct field
Index(P<Expr>, P<Expr>)
An indexing operation (foo[2]
)
Range(Option<P<Expr>>, Option<P<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, P<Expr>)
A referencing operation (&a
or &mut a
)
Break(Option<Label>, Option<P<Expr>>)
A break
, with an optional label to break, and an optional expression
Continue(Option<Label>)
A continue
, with an optional label
Ret(Option<P<Expr>>)
A return
, with an optional value to be returned
InlineAsm(P<InlineAsm>)
Output of the asm!()
macro
Mac(Mac)
A macro invocation; pre-expansion
Struct(Path, Vec<Field>, Option<P<Expr>>)
A struct literal expression.
For example, Foo {x: 1, y: 2}
, or
Foo {x: 1, .. base}
, where base
is the Option<Expr>
.
Repeat(P<Expr>, AnonConst)
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.
Paren(P<Expr>)
No-op: used solely so we can pretty-print faithfully
Try(P<Expr>)
expr?
Yield(Option<P<Expr>>)
A yield
, with an optional value to be yielded
Trait Implementations
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 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 Encodable for ExprKind
[src]
impl Encodable for ExprKind
impl Decodable for ExprKind
[src]
impl Decodable for ExprKind
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
type Owned = T
fn to_owned(&self) -> T
[src]
fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)
[src]
fn clone_into(&self, target: &mut T)
🔬 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]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 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> Encodable for T where
T: UseSpecializedEncodable + ?Sized,
impl<T> Decodable for T where
T: UseSpecializedDecodable,
[src]
impl<T> Decodable for T where
T: UseSpecializedDecodable,
impl<E> SpecializationError for E
[src]
impl<E> SpecializationError for E
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
[src]
fn not_found<S, T>(trait_name: &'static str, method_name: &'static str) -> E where
T: ?Sized,
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> Erased for T
impl<T> Send for T where
T: ?Sized,
[src]
impl<T> Send for T where
T: ?Sized,
impl<T> Sync for T where
T: ?Sized,
[src]
impl<T> Sync for T where
T: ?Sized,
impl<T> Erased for T
impl<T> Erased for T