Skip to main content

Statement

Enum Statement 

Source
pub enum Statement {
Show 22 variants Expression(Expression), VarDeclaration { kind: VarKind, decls: Vec<(Pattern, Option<Expression>)>, }, Block(Vec<Statement>), If { test: Expression, consequent: Box<Statement>, alternate: Option<Box<Statement>>, }, While { test: Expression, body: Box<Statement>, }, DoWhile { body: Box<Statement>, test: Expression, }, For { init: Option<Box<Statement>>, test: Option<Expression>, update: Option<Expression>, body: Box<Statement>, }, ForIn { decl_kind: Option<VarKind>, pattern: Pattern, object: Expression, body: Box<Statement>, of: bool, is_await: bool, }, FunctionDeclaration { name: String, params: Vec<Param>, body: Vec<Statement>, is_async: bool, is_generator: bool, }, Return(Option<Expression>), Break(Option<String>), Continue(Option<String>), Labeled(String, Box<Statement>), Throw(Expression), Switch { discriminant: Expression, cases: Vec<SwitchCase>, }, Try { block: Vec<Statement>, catch_param: Option<Pattern>, catch_block: Option<Vec<Statement>>, finally_block: Option<Vec<Statement>>, }, Import { source: String, default: Option<String>, namespace: Option<String>, named: Vec<(String, String)>, side_effect_only: bool, }, ExportNamed { specifiers: Vec<(String, String)>, source: Option<String>, }, ExportDefault(Expression), ExportDecl { declaration: Box<Statement>, names: Vec<String>, }, ExportAll { source: String, }, Empty,
}

Variants§

§

Expression(Expression)

§

VarDeclaration

Fields

§kind: VarKind
§

Block(Vec<Statement>)

§

If

Fields

§consequent: Box<Statement>
§alternate: Option<Box<Statement>>
§

While

Fields

§

DoWhile

Fields

§

For

§

ForIn

Fields

§decl_kind: Option<VarKind>
§pattern: Pattern
§object: Expression
§of: bool
§is_await: bool

for await (x of iterable)Symbol.asyncIterator があればそれを駆動し、 無ければ同期イテラブルの各要素を await するフォールバック(of の時のみ意味を持つ)。

§

FunctionDeclaration

Fields

§name: String
§params: Vec<Param>
§is_async: bool
§is_generator: bool
§

Return(Option<Expression>)

§

Break(Option<String>)

break; / break label;

§

Continue(Option<String>)

continue; / continue label;

§

Labeled(String, Box<Statement>)

label: statement(ラベル付き文。主にループの break label/continue label の ターゲットとして使う)。

§

Throw(Expression)

§

Switch

Fields

§discriminant: Expression
§

Try

Fields

§catch_param: Option<Pattern>

catch (e)/catch ({message}) 等。分割代入パターンにも対応(ES2015)。

§catch_block: Option<Vec<Statement>>
§finally_block: Option<Vec<Statement>>
§

Import

import ... from "spec" 宣言。 例: import def, { a, b as c }, * as ns from "mod"

Fields

§source: String

モジュール指定子(指定子文字列)。

§default: Option<String>

default インポートの束縛名(import def from ...)。

§namespace: Option<String>

名前空間インポートの束縛名(import * as ns from ...)。

§named: Vec<(String, String)>

名前付きインポート: (元の export 名, ローカル束縛名)。

§side_effect_only: bool

副作用のみ import "mod"(束縛なし)。

§

ExportNamed

export { a, b as c } / export { x } from "mod"(再エクスポート)。

Fields

§specifiers: Vec<(String, String)>

(ローカル名 or 元名, 公開する export 名)。

§source: Option<String>

再エクスポート元の指定子(export { x } from "mod")。None なら自モジュール。

§

ExportDefault(Expression)

export default <expr>

§

ExportDecl

export var/let/const/function/class ...(宣言を実行しつつ名前を export)。 内側の宣言文と、そこから公開する名前のリストを保持する。

Fields

§declaration: Box<Statement>
§names: Vec<String>
§

ExportAll

export * from "mod"(全名前の再エクスポート)。

Fields

§source: String
§

Empty

Trait Implementations§

Source§

impl Clone for Statement

Source§

fn clone(&self) -> Statement

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 Statement

Source§

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

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

impl PartialEq for Statement

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Statement

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> Same for T

Source§

type Output = T

Should always be Self
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 = 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.