pub enum Expr {
Show 17 variants
Lit(Literal),
Var(String),
Block(Block),
Call {
callee: Box<Expr>,
args: Vec<Expr>,
},
Pipe {
left: Box<Expr>,
right: Box<Expr>,
},
Try(Box<Expr>),
Field {
value: Box<Expr>,
field: String,
},
BinOp {
op: BinOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
UnaryOp {
op: UnaryOp,
expr: Box<Expr>,
},
If {
cond: Box<Expr>,
then_block: Block,
else_block: Block,
},
Match {
scrutinee: Box<Expr>,
arms: Vec<Arm>,
},
RecordLit(Vec<RecordLitField>),
TupleLit(Vec<Expr>),
ListLit(Vec<Expr>),
Constructor {
name: String,
args: Vec<Expr>,
},
Lambda(Box<Lambda>),
Ascription {
value: Box<Expr>,
ty: TypeExpr,
},
}Variants§
Lit(Literal)
Var(String)
Block(Block)
Call
Pipe
Try(Box<Expr>)
expr? postfix.
Field
expr.field
BinOp
UnaryOp
If
Match
RecordLit(Vec<RecordLitField>)
TupleLit(Vec<Expr>)
ListLit(Vec<Expr>)
Constructor
A bare constructor name (None, Empty) or constructor call (Ok(x)).
Since we cannot distinguish a constructor from a variable at parse
time, the parser emits Var/Call and the type checker resolves it.
This variant is kept for the canonicalizer to lift detected
constructors into.
Lambda(Box<Lambda>)
Ascription
Inline type ascription (expr :: Type). The declared type is checked
against the inferred type at type-check time; at runtime it compiles
identically to the inner expression (type-only annotation, erased at
bytecode level). (#319)
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 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