ClonableFn

Trait ClonableFn 

Source
pub trait ClonableFn: Category {
    type Output<'a, A: 'a, B: 'a>: Clone + Deref<Target = dyn Fn(A) -> B + 'a>;

    // Required method
    fn new<'a, A: 'a, B: 'a>(f: impl 'a + Fn(A) -> B) -> ApplyFn<'a, Self, A, B>;
}
Expand description

Abstraction for clonable wrappers over closures.

This trait is implemented by “Brand” types (like ArcFnBrand and RcFnBrand) to provide a way to construct and type-check clonable wrappers over closures (Arc<dyn Fn...> or Rc<dyn Fn...>) in a generic context, allowing library users to choose between implementations at function call sites.

The lifetime 'a ensures the function doesn’t outlive referenced data, while generic types A and B represent the input and output types, respectively.

Required Associated Types§

Source

type Output<'a, A: 'a, B: 'a>: Clone + Deref<Target = dyn Fn(A) -> B + 'a>

Required Methods§

Source

fn new<'a, A: 'a, B: 'a>(f: impl 'a + Fn(A) -> B) -> ApplyFn<'a, Self, A, B>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl ClonableFn for ArcFnBrand

Source§

type Output<'a, A: 'a, B: 'a> = <ArcFnBrand as Kind1L2T>::Output<'a, A, B>

Source§

impl ClonableFn for RcFnBrand

Source§

type Output<'a, A: 'a, B: 'a> = <RcFnBrand as Kind1L2T>::Output<'a, A, B>