pub enum Stmt {
Expr(Expr),
Let {
name: String,
init: Option<Expr>,
mutable: bool,
},
Block(Vec<Stmt>),
If {
test: Expr,
consequent: Box<Stmt>,
alternate: Option<Box<Stmt>>,
},
While {
test: Expr,
body: Box<Stmt>,
},
For {
init: Option<Box<Stmt>>,
test: Option<Expr>,
update: Option<Expr>,
body: Box<Stmt>,
},
ForIn {
variable: String,
iterable: Expr,
body: Box<Stmt>,
},
Return(Option<Expr>),
Break,
Continue,
TryCatch {
body: Box<Stmt>,
catch_param: Option<String>,
catch_body: Option<Box<Stmt>>,
finally_body: Option<Box<Stmt>>,
},
Function(Function),
}Expand description
A statement (doesn’t produce a value directly).
Variants§
Expr(Expr)
Expression statement: expr;.
Let
Variable declaration: let name = init or const name = init.
Block(Vec<Stmt>)
Block: { stmts... }.
If
If statement: if (test) consequent else alternate.
While
While loop: while (test) body.
For
For loop: for (init; test; update) body.
ForIn
For-in/for-of loop: for (variable in/of iterable) body.
Return(Option<Expr>)
Return statement: return expr.
Break
Break statement.
Continue
Continue statement.
TryCatch
Try/catch/finally statement.
Fields
Function(Function)
Function declaration.
Implementations§
Source§impl Stmt
impl Stmt
pub fn expr(e: Expr) -> Self
pub fn let_decl(name: impl Into<String>, init: Option<Expr>) -> Self
pub fn const_decl(name: impl Into<String>, init: Expr) -> Self
pub fn block(stmts: Vec<Stmt>) -> Self
pub fn if_stmt(test: Expr, consequent: Stmt, alternate: Option<Stmt>) -> Self
pub fn while_loop(test: Expr, body: Stmt) -> Self
pub fn for_loop( init: Option<Stmt>, test: Option<Expr>, update: Option<Expr>, body: Stmt, ) -> Self
pub fn for_in(variable: impl Into<String>, iterable: Expr, body: Stmt) -> Self
pub fn return_stmt(expr: Option<Expr>) -> Self
pub fn break_stmt() -> Self
pub fn continue_stmt() -> Self
pub fn try_catch( body: Stmt, catch_param: Option<String>, catch_body: Option<Stmt>, finally_body: Option<Stmt>, ) -> Self
pub fn function(f: Function) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Stmt
impl<'de> Deserialize<'de> for Stmt
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
Source§impl StructureEq for Stmt
impl StructureEq for Stmt
Source§fn structure_eq(&self, other: &Self) -> bool
fn structure_eq(&self, other: &Self) -> bool
Compare two values for structural equality.
impl StructuralPartialEq for Stmt
Auto Trait Implementations§
impl Freeze for Stmt
impl RefUnwindSafe for Stmt
impl Send for Stmt
impl Sync for Stmt
impl Unpin 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