Struct swc_ecma_utils::function::FunctionWrapper
source · 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§
source§impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
impl From<FunctionWrapper<Expr>> for FnWrapperResult<FnExpr, FnDecl>
source§fn from(value: FunctionWrapper<Expr>) -> Self
fn from(value: FunctionWrapper<Expr>) -> Self
Converts to this type from the input type.
source§impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
impl From<FunctionWrapper<FnDecl>> for FnWrapperResult<FnDecl, FnDecl>
source§fn from(value: FunctionWrapper<FnDecl>) -> Self
fn from(value: FunctionWrapper<FnDecl>) -> Self
Converts to this type from the input type.
source§impl Into<Expr> for FunctionWrapper<Expr>
impl Into<Expr> for FunctionWrapper<Expr>
source§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.