pub enum Stmt {
Let {
name: String,
ty: Option<TypeAnn>,
value: Expr,
span: Span,
},
Var {
name: String,
ty: Option<TypeAnn>,
value: Option<Expr>,
span: Span,
},
Assign {
name: String,
name_span: Span,
op: AssignOp,
value: Expr,
span: Span,
},
Func {
name: String,
params: Vec<Param>,
ret: Option<TypeAnn>,
body: Vec<Stmt>,
span: Span,
},
Return {
value: Option<Expr>,
span: Span,
},
Struct {
name: String,
fields: Vec<FieldDef>,
span: Span,
},
Enum {
name: String,
variants: Vec<VariantDef>,
span: Span,
},
If {
cond: Expr,
then_body: Vec<Stmt>,
else_body: Option<Vec<Stmt>>,
span: Span,
},
While {
cond: Expr,
body: Vec<Stmt>,
span: Span,
},
For {
var: String,
iter: Expr,
body: Vec<Stmt>,
span: Span,
},
Expr(Expr),
}Variants§
Let
let name = value — an immutable binding.
Var
var name = value or var name: type — a mutable binding.
Assign
name = value, name += value, name -= value.
Func
func name(params) -> ret { body }. A missing -> ret means the
function returns nothing.
Return
return or return value.
Struct
struct Name { field: type ... } — declares a record type.
Enum
enum Name { case ... } — declares a type that is exactly one of a
fixed set of cases, each of which may carry its own values.
If
if cond { ... } else { ... }. An else if is represented as an
else body holding a single nested If.
While
while cond { ... }.
For
for var in iter { ... }, where iter is an array or a range.
Expr(Expr)
A bare expression run for its effect, like print("hi").
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Stmt
impl RefUnwindSafe for Stmt
impl Send for Stmt
impl Sync for Stmt
impl Unpin for Stmt
impl UnsafeUnpin for Stmt
impl UnwindSafe for Stmt
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