Skip to main content

TsStmt

Struct TsStmt 

Source
pub struct TsStmt(pub Stmt);
Expand description

Wrapper for swc_core::ecma::ast::Stmt that implements [Display].

This allows statements to be interpolated into string-based templates.

§Example

use macroforge_ts_syn::TsStmt;

let stmt: Stmt = /* ... */;
let wrapped = TsStmt(stmt);
println!("{}", wrapped); // Emits the statement

Tuple Fields§

§0: Stmt

Methods from Deref<Target = Stmt>§

Source

pub fn is_block(&self) -> bool

Returns true if self is of variant Block.

Source

pub fn as_block(&self) -> Option<&BlockStmt>

Returns Some if self is a reference of variant Block, and None otherwise.

Source

pub fn is_empty(&self) -> bool

Returns true if self is of variant Empty.

Source

pub fn as_empty(&self) -> Option<&EmptyStmt>

Returns Some if self is a reference of variant Empty, and None otherwise.

Source

pub fn is_debugger(&self) -> bool

Returns true if self is of variant Debugger.

Source

pub fn as_debugger(&self) -> Option<&DebuggerStmt>

Returns Some if self is a reference of variant Debugger, and None otherwise.

Source

pub fn is_with(&self) -> bool

Returns true if self is of variant With.

Source

pub fn as_with(&self) -> Option<&WithStmt>

Returns Some if self is a reference of variant With, and None otherwise.

Source

pub fn is_return_stmt(&self) -> bool

Returns true if self is of variant Return.

Source

pub fn as_return_stmt(&self) -> Option<&ReturnStmt>

Returns Some if self is a reference of variant Return, and None otherwise.

Source

pub fn is_labeled(&self) -> bool

Returns true if self is of variant Labeled.

Source

pub fn as_labeled(&self) -> Option<&LabeledStmt>

Returns Some if self is a reference of variant Labeled, and None otherwise.

Source

pub fn is_break_stmt(&self) -> bool

Returns true if self is of variant Break.

Source

pub fn as_break_stmt(&self) -> Option<&BreakStmt>

Returns Some if self is a reference of variant Break, and None otherwise.

Source

pub fn is_continue_stmt(&self) -> bool

Returns true if self is of variant Continue.

Source

pub fn as_continue_stmt(&self) -> Option<&ContinueStmt>

Returns Some if self is a reference of variant Continue, and None otherwise.

Source

pub fn is_if_stmt(&self) -> bool

Returns true if self is of variant If.

Source

pub fn as_if_stmt(&self) -> Option<&IfStmt>

Returns Some if self is a reference of variant If, and None otherwise.

Source

pub fn is_switch(&self) -> bool

Returns true if self is of variant Switch.

Source

pub fn as_switch(&self) -> Option<&SwitchStmt>

Returns Some if self is a reference of variant Switch, and None otherwise.

Source

pub fn is_throw(&self) -> bool

Returns true if self is of variant Throw.

Source

pub fn as_throw(&self) -> Option<&ThrowStmt>

Returns Some if self is a reference of variant Throw, and None otherwise.

Source

pub fn is_try_stmt(&self) -> bool

Returns true if self is of variant Try.

Source

pub fn as_try_stmt(&self) -> Option<&Box<TryStmt>>

Returns Some if self is a reference of variant Try, and None otherwise.

Source

pub fn is_while_stmt(&self) -> bool

Returns true if self is of variant While.

Source

pub fn as_while_stmt(&self) -> Option<&WhileStmt>

Returns Some if self is a reference of variant While, and None otherwise.

Source

pub fn is_do_while(&self) -> bool

Returns true if self is of variant DoWhile.

Source

pub fn as_do_while(&self) -> Option<&DoWhileStmt>

Returns Some if self is a reference of variant DoWhile, and None otherwise.

Source

pub fn is_for_stmt(&self) -> bool

Returns true if self is of variant For.

Source

pub fn as_for_stmt(&self) -> Option<&ForStmt>

Returns Some if self is a reference of variant For, and None otherwise.

Source

pub fn is_for_in(&self) -> bool

Returns true if self is of variant ForIn.

Source

pub fn as_for_in(&self) -> Option<&ForInStmt>

Returns Some if self is a reference of variant ForIn, and None otherwise.

Source

pub fn is_for_of(&self) -> bool

Returns true if self is of variant ForOf.

Source

pub fn as_for_of(&self) -> Option<&ForOfStmt>

Returns Some if self is a reference of variant ForOf, and None otherwise.

Source

pub fn is_decl(&self) -> bool

Returns true if self is of variant Decl.

Source

pub fn as_decl(&self) -> Option<&Decl>

Returns Some if self is a reference of variant Decl, and None otherwise.

Source

pub fn is_expr(&self) -> bool

Returns true if self is of variant Expr.

Source

pub fn as_expr(&self) -> Option<&ExprStmt>

Returns Some if self is a reference of variant Expr, and None otherwise.

Source

pub fn is_use_strict(&self) -> bool

Source

pub fn can_precede_directive(&self) -> bool

Returns true if the statement does not prevent the directives below self from being directives.

Trait Implementations§

Source§

impl Clone for TsStmt

Source§

fn clone(&self) -> TsStmt

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TsStmt

Source§

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

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

impl Deref for TsStmt

Available on crate feature swc only.
Source§

type Target = Stmt

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Display for TsStmt

Available on crate feature swc only.
Source§

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

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

impl From<Stmt> for TsStmt

Available on crate feature swc only.
Source§

fn from(stmt: Stmt) -> Self

Converts to this type from the input type.

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> ImplicitClone for T
where T: Clone,

Source§

fn clone_quote_var(&self) -> Self

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

fn to_compact_string(&self) -> CompactString

Converts the given value to a CompactString. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

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