Struct swc_plugin::utils::function::FunctionWrapper
[−]pub struct FunctionWrapper<T> {
pub binding_ident: Option<Ident>,
pub function: Expr,
pub ignore_function_name: bool,
pub ignore_function_length: bool,
/* private fields */
}
Fields
binding_ident: Option<Ident>
function: Expr
ignore_function_name: bool
ignore_function_length: bool
Trait Implementations
impl From<ArrowExpr> for FunctionWrapper<Expr>
impl From<ArrowExpr> for FunctionWrapper<Expr>
fn from(ArrowExpr) -> FunctionWrapper<Expr>
fn from(ArrowExpr) -> FunctionWrapper<Expr>
Converts to this type from the input type.
impl From<FnDecl> for FunctionWrapper<FnDecl>
impl From<FnDecl> for FunctionWrapper<FnDecl>
fn from(fn_decl: FnDecl) -> FunctionWrapper<FnDecl>
fn from(fn_decl: FnDecl) -> FunctionWrapper<FnDecl>
Converts to this type from the input type.
impl From<FnExpr> for FunctionWrapper<Expr>
impl From<FnExpr> for FunctionWrapper<Expr>
fn from(fn_expr: FnExpr) -> FunctionWrapper<Expr>
fn from(fn_expr: FnExpr) -> FunctionWrapper<Expr>
Converts to this type from the input type.
impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
fn from(value: FunctionWrapper<Expr>) -> FnWrapperResult<FnExpr, FnDecl>
fn from(value: FunctionWrapper<Expr>) -> FnWrapperResult<FnExpr, FnDecl>
Converts to this type from the input type.
impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
fn from(value: FunctionWrapper<FnDecl>) -> FnWrapperResult<FnDecl, FnDecl>
fn from(value: FunctionWrapper<FnDecl>) -> FnWrapperResult<FnDecl, FnDecl>
Converts to this type from the input type.
impl Into<Expr> for FunctionWrapper<Expr>
impl Into<Expr> for FunctionWrapper<Expr>
fn into(self) -> Expr
fn into(self) -> Expr
If a function has a function name, it may be called recursively. We use the named expression to hoist the function name internally Therefore, its recursive calls refer to the correct identity.
Else if a function has a binding name, it may be called recursively as well. But it refer the binding name which exist the outer scope. It is safe to using anonymous expression wrapper.
Optimization: A function without a name cannot be recursively referenced by Ident. It’s safe to return the expr without wrapper if the params.len is 0.
Auto Trait Implementations
impl<T> RefUnwindSafe for FunctionWrapper<T> where
T: RefUnwindSafe,
impl<T> Send for FunctionWrapper<T> where
T: Send,
impl<T> Sync for FunctionWrapper<T> where
T: Sync,
impl<T> Unpin for FunctionWrapper<T> where
T: Unpin,
impl<T> UnwindSafe for FunctionWrapper<T> where
T: UnwindSafe,
Blanket Implementations
impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
&<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for F where
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
impl<T> ExprFactory for T where
T: Into<Expr>,
impl<T> ExprFactory for T where
T: Into<Expr>,
fn as_arg(self) -> ExprOrSpread
fn as_arg(self) -> ExprOrSpread
Creates an ExprOrSpread using the given Expr. Read more
fn as_pat_or_expr(self) -> PatOrExpr
fn into_return_stmt(self) -> ReturnStmt
fn into_return_stmt(self) -> ReturnStmt
Creates a statement whcih return self
.
fn as_callee(self) -> Callee
fn as_iife(self) -> CallExpr
fn into_lazy_arrow(self, params: Vec<Pat, Global>) -> ArrowExpr
fn into_lazy_arrow(self, params: Vec<Pat, Global>) -> ArrowExpr
create a ArrowExpr which return self Read more
fn into_lazy_fn(self, params: Vec<Param, Global>) -> Function
fn into_lazy_fn(self, params: Vec<Param, Global>) -> Function
create a Function which return self Read more
fn into_lazy_auto(self, params: Vec<Pat, Global>, support_arrow: bool) -> Expr
fn into_var_decl(self, kind: VarDeclKind, name: Pat) -> VarDecl
fn into_var_decl(self, kind: VarDeclKind, name: Pat) -> VarDecl
create a var declartor using self as init Read more
fn into_new_expr(
self,
span: Span,
args: Option<Vec<ExprOrSpread, Global>>
) -> NewExpr
fn apply(
self,
span: Span,
this: Box<Expr, Global>,
args: Vec<ExprOrSpread, Global>
) -> Expr
fn call_fn(self, span: Span, args: Vec<ExprOrSpread, Global>) -> Expr
fn as_call(self, span: Span, args: Vec<ExprOrSpread, Global>) -> Expr
fn as_fn_decl(self) -> Option<FnDecl>
fn as_class_decl(self) -> Option<ClassDecl>
fn wrap_with_paren(self) -> Expr
fn make_bin<T>(self, op: BinaryOp, right: T) -> Expr where
T: Into<Expr>,
fn make_bin<T>(self, op: BinaryOp, right: T) -> Expr where
T: Into<Expr>,
Creates a binary expr $self $op $rhs
fn make_assign_to(self, op: AssignOp, left: PatOrExpr) -> Expr
fn make_assign_to(self, op: AssignOp, left: PatOrExpr) -> Expr
Creates a assign expr $lhs $op $self
fn make_member<T>(self, prop: T) -> Expr where
T: Into<Ident>,
fn computed_member<T>(self, prop: T) -> Expr where
T: Into<Expr>,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more