#[repr(transparent)]
pub struct Method<F>(pub F);
Expand description

The wrapper for method functions

The method-like functions is functions which get this as the first argument. This wrapper allows receive this directly as first argument and do not requires using This for that purpose.

let func = Function::new(ctx, Method(|this: i32, factor: i32| {
    this * factor
}))?;
assert_eq!(func.call::<_, i32>((This(3), 2))?, 6);

Tuple Fields§

§0: F

Trait Implementations§

source§

impl<'js, F, R, T> AsFunction<'js, (T,), R> for Method<F>where F: Fn(T) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A> AsFunction<'js, (T, A), R> for Method<F>where F: Fn(T, A) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A, B> AsFunction<'js, (T, A, B), R> for Method<F>where F: Fn(T, A, B) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A, B, D> AsFunction<'js, (T, A, B, D), R> for Method<F>where F: Fn(T, A, B, D) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A, B, D, E> AsFunction<'js, (T, A, B, D, E), R> for Method<F>where F: Fn(T, A, B, D, E) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A, B, D, E, G> AsFunction<'js, (T, A, B, D, E, G), R> for Method<F>where F: Fn(T, A, B, D, E, G) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<'js, F, R, T, A, B, D, E, G, H> AsFunction<'js, (T, A, B, D, E, G, H), R> for Method<F>where F: Fn(T, A, B, D, E, G, H) -> R + 'js, R: IntoJs<'js>, T: FromJs<'js>, A: FromInput<'js>, B: FromInput<'js>, D: FromInput<'js>, E: FromInput<'js>, G: FromInput<'js>, H: FromInput<'js>,

source§

fn num_args() -> Range<usize>

The possible range of function arguments
source§

fn call(&self, input: &Input<'js>) -> Result<Value<'js>>

Call as JS function
source§

fn post<'js_>(_ctx: Ctx<'js_>, _func: &Function<'js_>) -> Result<()>

Post-processing the function
source§

impl<F> AsRef<F> for Method<F>

source§

fn as_ref(&self) -> &F

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<F> Deref for Method<F>

§

type Target = F

The resulting type after dereferencing.
source§

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

Dereferences the value.

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Method<F>where F: RefUnwindSafe,

§

impl<F> Send for Method<F>where F: Send,

§

impl<F> Sync for Method<F>where F: Sync,

§

impl<F> Unpin for Method<F>where F: Unpin,

§

impl<F> UnwindSafe for Method<F>where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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> ParallelSend for T