pub enum Expr {
Show 16 variants
Literal(Literal),
Path(Path),
MethodCall {
receiver: Option<Box<Expr>>,
name: Ident,
args: Vec<Expr>,
},
Field {
value: Box<Expr>,
name: Ident,
},
Index {
value: Box<Expr>,
index: Box<Expr>,
},
New {
type_: Box<Type>,
args: Vec<Expr>,
},
NewArray {
element: Box<Type>,
lengths: Vec<Expr>,
elements: Vec<Expr>,
},
Binary {
op: &'static str,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Paren(Box<Expr>),
Cast {
type_: Box<Type>,
value: Box<Expr>,
},
InstanceOf {
value: Box<Expr>,
type_: Box<Type>,
},
Ternary {
condition: Box<Expr>,
then: Box<Expr>,
otherwise: Box<Expr>,
},
This,
Lambda {
params: Vec<Ident>,
body: Box<Expr>,
},
Annotation(Annotation),
ArrayInit(Vec<Expr>),
}Expand description
An expression.
Variants§
Literal(Literal)
A literal.
Path(Path)
A name or qualified name.
MethodCall
receiver.name(args)
Fields
Field
value.name
Index
a[i]
New
new T(args)
NewArray
new T[]{ a, b }, new T[n], new T[n][m], new T[n][].
Fields
Binary
a op b
Paren(Box<Expr>)
(value), written because the writer meant it.
The tree carries no precedence and the renderer adds no
brackets, so a caller that needs one says so. Java’s & binds
looser than !=, which makes bits & mask != 0 a type error
where C reads it as a comparison — and looser than ^, which
makes bits & a ^ b a different number with nothing to say so.
Cast
(T) value
InstanceOf
value instanceof T
Ternary
cond ? a : b
Fields
This
this
Lambda
A lambda: (a, b) -> body.
Annotation(Annotation)
An annotation used as a value: an element of an annotation type that is itself an annotation, or of an array of them.
ArrayInit(Vec<Expr>)
{ a, b }, the array initialiser of an annotation element.
Trait Implementations§
impl Eq for Expr
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more