Skip to main content

StatementKind

Enum StatementKind 

Source
pub enum StatementKind {
Show 20 variants Block { body: Vec<Statement>, }, Empty, Debugger, Expression { expression: Expression, }, If { test: Expression, consequent: Box<Statement>, alternate: Option<Box<Statement>>, }, Switch { discriminant: Expression, cases: Vec<SwitchCase>, }, For { init: Option<ForInit>, test: Option<Expression>, update: Option<Expression>, body: Box<Statement>, }, ForIn { left: ForLeft, right: Expression, body: Box<Statement>, }, ForOf { left: ForLeft, right: Expression, body: Box<Statement>, is_await: bool, }, While { test: Expression, body: Box<Statement>, }, DoWhile { body: Box<Statement>, test: Expression, }, Return { argument: Option<Expression>, }, Throw { argument: Expression, }, Try { block: Vec<Statement>, handler: Option<CatchClause>, finalizer: Option<Vec<Statement>>, }, Break { label: Option<Identifier>, }, Continue { label: Option<Identifier>, }, Labeled { label: Identifier, body: Box<Statement>, }, VariableDeclaration(VariableDeclaration), FunctionDeclaration(Function), ClassDeclaration(Class),
}
Expand description

The shape of an ECMAScript statement.

Variants§

§

Block

A block: { ... }.

Fields

§body: Vec<Statement>

Statements inside the block.

§

Empty

An empty statement (;).

§

Debugger

debugger;

§

Expression

An expression evaluated as a statement.

Fields

§expression: Expression

The expression.

§

If

if (test) consequent else? alternate.

Fields

§test: Expression

The test expression.

§consequent: Box<Statement>

The body run when test is truthy.

§alternate: Option<Box<Statement>>

The optional else branch.

§

Switch

switch (discriminant) { cases }.

Fields

§discriminant: Expression

The discriminant expression.

§cases: Vec<SwitchCase>

The cases.

§

For

for (init; test; update) body.

Fields

§init: Option<ForInit>

Optional initialiser (declaration or expression).

§test: Option<Expression>

Optional loop-continuation test.

§update: Option<Expression>

Optional update expression evaluated after each iteration.

§body: Box<Statement>

The loop body.

§

ForIn

for (left in right) body.

Fields

§left: ForLeft

The iteration target (declaration or assignment-target pattern).

§right: Expression

The object whose enumerable properties are iterated.

§body: Box<Statement>

The loop body.

§

ForOf

for (left of right) body, possibly for await.

Fields

§left: ForLeft

The iteration target.

§right: Expression

The iterable expression.

§body: Box<Statement>

The loop body.

§is_await: bool

True for for await (...) of.

§

While

while (test) body.

Fields

§test: Expression

The test expression.

§body: Box<Statement>

The loop body.

§

DoWhile

do body while (test);.

Fields

§body: Box<Statement>

The loop body.

§test: Expression

The test expression checked after each iteration.

§

Return

return argument?;

Fields

§argument: Option<Expression>

Optional return value.

§

Throw

throw argument;

Fields

§argument: Expression

The value to throw.

§

Try

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

Fields

§block: Vec<Statement>

The protected block.

§handler: Option<CatchClause>

Optional catch clause.

§finalizer: Option<Vec<Statement>>

Optional finally block.

§

Break

break label?;

Fields

§label: Option<Identifier>

Optional label to break out of.

§

Continue

continue label?;

Fields

§label: Option<Identifier>

Optional label to continue.

§

Labeled

label: body – attach a label to a loop or block.

Fields

§label: Identifier

The label name.

§body: Box<Statement>

The labelled statement.

§

VariableDeclaration(VariableDeclaration)

A variable declaration treated as a statement.

§

FunctionDeclaration(Function)

A function declaration.

§

ClassDeclaration(Class)

A class declaration.

Trait Implementations§

Source§

impl Clone for StatementKind

Source§

fn clone(&self) -> StatementKind

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 StatementKind

Source§

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

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

impl Display for StatementKind

Source§

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

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

impl Eq for StatementKind

Source§

impl PartialEq for StatementKind

Source§

fn eq(&self, other: &StatementKind) -> 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 StatementKind

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.