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.
Auto Trait Implementations§
impl<T> Freeze for FunctionWrapper<T>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> ExprFactory for T
impl<T> ExprFactory for T
source§fn as_arg(self) -> ExprOrSpread
fn as_arg(self) -> ExprOrSpread
fn as_pat_or_expr(self) -> PatOrExpr
source§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
source§fn into_lazy_arrow(self, params: Vec<Pat>) -> ArrowExpr
fn into_lazy_arrow(self, params: Vec<Pat>) -> ArrowExpr
create a ArrowExpr which return self Read more
source§fn into_lazy_fn(self, params: Vec<Param>) -> Function
fn into_lazy_fn(self, params: Vec<Param>) -> Function
create a Function which return self Read more
fn into_lazy_auto(self, params: Vec<Pat>, support_arrow: bool) -> Expr
source§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>>) -> NewExpr
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 as_fn_decl(self) -> Option<FnDecl>
fn as_class_decl(self) -> Option<ClassDecl>
fn wrap_with_paren(self) -> Expr
source§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
fn computed_member<T>(self, prop: T) -> Expr
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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