Skip to main content

StmtKind

Enum StmtKind 

Source
pub enum StmtKind {
Show 23 variants Empty, Block(Vec<Stmt>), Expr(Box<Expr>), If { test: Box<Expr>, cons: Box<Stmt>, alt: Option<Box<Stmt>>, }, DoWhile { body: Box<Stmt>, test: Box<Expr>, }, While { test: Box<Expr>, body: Box<Stmt>, }, For { init: Option<ForInit>, test: Option<Box<Expr>>, update: Option<Box<Expr>>, body: Box<Stmt>, }, ForIn { left: ForHead, right: Box<Expr>, body: Box<Stmt>, }, ForOf { is_await: bool, left: ForHead, right: Box<Expr>, body: Box<Stmt>, }, Continue(Option<Ident>), Break(Option<Ident>), Return(Option<Box<Expr>>), With { object: Box<Expr>, body: Box<Stmt>, }, Labeled { label: Ident, body: Box<Stmt>, }, Switch { discriminant: Box<Expr>, cases: Vec<SwitchCase>, }, Throw(Box<Expr>), Try { block: Vec<Stmt>, handler: Option<CatchClause>, finalizer: Option<Vec<Stmt>>, }, Debugger, VarDecl(VarDecl), FuncDecl(Box<Function>), ClassDecl(Box<Class>), Import(Box<ImportDecl>), Export(Box<ExportDecl>),
}
Expand description

Statement and declaration nodes (StatementListItem).

Variants§

§

Empty

;

§

Block(Vec<Stmt>)

{ ... }

§

Expr(Box<Expr>)

expr;

§

If

if (test) cons else alt

Fields

§test: Box<Expr>

Condition.

§cons: Box<Stmt>

Then branch.

§alt: Option<Box<Stmt>>

Else branch.

§

DoWhile

do body while (test);

Fields

§body: Box<Stmt>

Loop body.

§test: Box<Expr>

Loop condition.

§

While

while (test) body

Fields

§test: Box<Expr>

Loop condition.

§body: Box<Stmt>

Loop body.

§

For

for (init; test; update) body

Fields

§init: Option<ForInit>

null for for (;;), otherwise a var/let/const declaration or an expression.

§test: Option<Box<Expr>>

Loop condition.

§update: Option<Box<Expr>>

Per-iteration update expression.

§body: Box<Stmt>

Loop body.

§

ForIn

for (decl|lhs in expr) body

Fields

§left: ForHead

Left-hand side.

§right: Box<Expr>

Enumerated object.

§body: Box<Stmt>

Loop body.

§

ForOf

for (decl|lhs of expr) body, plus for await (…)

Fields

§is_await: bool

Whether await was present.

§left: ForHead

Left-hand side.

§right: Box<Expr>

Iterated value.

§body: Box<Stmt>

Loop body.

§

Continue(Option<Ident>)

continue; / continue label;

§

Break(Option<Ident>)

break; / break label;

§

Return(Option<Box<Expr>>)

return; / return expr;

§

With

with (obj) body

Fields

§object: Box<Expr>

Object to put on the scope chain.

§body: Box<Stmt>

Statement executed inside the with.

§

Labeled

label: stmt

Fields

§label: Ident

Label name.

§body: Box<Stmt>

Labelled statement.

§

Switch

switch (disc) { cases }

Fields

§discriminant: Box<Expr>

Discriminant.

§cases: Vec<SwitchCase>

Cases in source order.

§

Throw(Box<Expr>)

throw expr;

§

Try

try { } catch (e) { } finally { }

Fields

§block: Vec<Stmt>

Guarded block.

§handler: Option<CatchClause>

Catch clause, if present.

§finalizer: Option<Vec<Stmt>>

Finalizer block, if present.

§

Debugger

debugger;

§

VarDecl(VarDecl)

var/let/const declaration.

§

FuncDecl(Box<Function>)

function declaration.

§

ClassDecl(Box<Class>)

class declaration.

§

Import(Box<ImportDecl>)

import declaration (modules only).

§

Export(Box<ExportDecl>)

export declaration (modules only).

Trait Implementations§

Source§

impl Clone for StmtKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StmtKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for StmtKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for StmtKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.