pub enum Expr {
Show 18 variants
Ident(Identifier),
Literal {
value: String,
span: Range<usize>,
},
Bool {
value: bool,
span: Range<usize>,
},
Unary {
op: RustTokenType,
expr: Box<Expr>,
span: Range<usize>,
},
Binary {
left: Box<Expr>,
op: RustTokenType,
right: Box<Expr>,
span: Range<usize>,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
span: Range<usize>,
},
Field {
receiver: Box<Expr>,
field: Identifier,
span: Range<usize>,
},
Index {
receiver: Box<Expr>,
index: Box<Expr>,
span: Range<usize>,
},
Paren {
expr: Box<Expr>,
span: Range<usize>,
},
Block(Block),
If {
condition: Box<Expr>,
then_block: Block,
else_block: Option<Block>,
span: Range<usize>,
},
While {
condition: Box<Expr>,
body: Block,
span: Range<usize>,
},
For {
var: Identifier,
iter: Box<Expr>,
body: Block,
span: Range<usize>,
},
Loop {
body: Block,
span: Range<usize>,
},
Match {
expr: Box<Expr>,
arms: Vec<MatchArm>,
span: Range<usize>,
},
Tuple {
elements: Vec<Expr>,
span: Range<usize>,
},
Array {
elements: Vec<Expr>,
span: Range<usize>,
},
Struct {
path: String,
fields: Vec<FieldInit>,
span: Range<usize>,
},
}Expand description
Represents different types of expressions in Rust source code.
Expressions are constructs that evaluate to values and can be used in various contexts.
Variants§
Ident(Identifier)
An identifier expression
Literal
A literal expression
Fields
Bool
A boolean literal expression
Fields
Unary
A unary expression (e.g., !x, -x, *x, &x)
Fields
§
op: RustTokenTypeThe unary operator
Binary
A binary expression (e.g., x + y, x == y)
Fields
§
op: RustTokenTypeThe binary operator
Call
A function call expression
Fields
Field
A field access expression (e.g., obj.field)
Fields
§
field: IdentifierThe field being accessed
Index
An index expression (e.g., arr[0])
Fields
Paren
A parenthesized expression
Fields
Block(Block)
A block expression
If
An if expression
Fields
While
A while loop expression
Fields
For
A for loop expression
Fields
§
var: IdentifierThe loop variable
Loop
A loop expression
Fields
Match
A match expression
Fields
Tuple
A tuple expression
Fields
Array
An array expression
Fields
Struct
A struct expression
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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 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