pub trait ExprFactory: Into<Expr> {
    fn as_arg(self) -> ExprOrSpread { ... }
    fn into_stmt(self) -> Stmt { ... }
    fn as_callee(self) -> Callee { ... }
    fn as_iife(self) -> CallExpr { ... }
    fn apply(self, span: Span, this: Box<Expr>, args: Vec<ExprOrSpread>) -> Expr { ... }
    fn call_fn(self, span: Span, args: Vec<ExprOrSpread>) -> Expr { ... }
    fn as_call(self, span: Span, args: Vec<ExprOrSpread>) -> Expr { ... }
    fn wrap_with_paren(self) -> Expr { ... }
    fn make_eq<T>(self, right: T) -> Expr
    where
        T: Into<Expr>
, { ... } fn make_bin<T>(self, op: BinaryOp, right: T) -> Expr
    where
        T: Into<Expr>
, { ... } fn make_member<T>(self, prop: T) -> Expr
    where
        T: Into<Ident>
, { ... } fn computed_member<T>(self, prop: T) -> Expr
    where
        T: Into<Expr>
, { ... } }
Expand description

Extension methods for Expr.

Note that many types implements Into<Expr> and you can do like

use swc_ecma_utils::ExprFactory;

let _args = vec![0f64.as_arg()];

to create literals. Almost all rust core types implements Into<Expr>.

Provided Methods

Creates an ExprOrSpread using the given Expr.

This is recommended way to create ExprOrSpread.

Example
use swc_common::DUMMY_SP;
use swc_ecma_ast::*;
use swc_ecma_utils::ExprFactory;

let first = Lit::Num(Number {
    span: DUMMY_SP,
    value: 0.0,
    raw: None,
});
let _args = vec![first.as_arg()];

Creates an expression statement with self.

Creates a binary expr $self ===

Creates a binary expr $self $op $rhs

Implementors