Skip to main content

StaticRefFunction

Trait StaticRefFunction 

Source
pub trait StaticRefFunction<'a, D, T> {
    type Output;

    // Required method
    fn call(data: &'a D, arg: T) -> Self::Output;

    // Provided methods
    fn bind(data: &'a D) -> RefFn<'a, T, Self::Output> { ... }
    fn bind_sync(data: &'a D) -> RefSyncFn<'a, T, Self::Output>
       where D: Sync { ... }
}
Expand description

A trait for defining a static function will be type erased.

Required Associated Types§

Source

type Output

Return type of the defined function.

Required Methods§

Source

fn call(data: &'a D, arg: T) -> Self::Output

Function definition.

Provided Methods§

Source

fn bind(data: &'a D) -> RefFn<'a, T, Self::Output>

A helper function to create a RefFn object with the defined function.

Source

fn bind_sync(data: &'a D) -> RefSyncFn<'a, T, Self::Output>
where D: Sync,

A helper function to create a RefSyncFn object with the defined function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a, T, F, R> StaticRefFunction<'a, F, T> for F
where F: Fn(T) -> R,