pub trait ClonableFn: Kind1L2T + Clone {
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,
) -> <Self as ClonableFn>::Output<'a, A, B>;
}
Expand description
Abstracts over smart pointers for clonable closures.
This trait is implemented by zero-sized “Brand” types (like ArcBrand
and RcBrand
)
to provide a way to construct and type-check function wrappers (Arc<dyn Fn...>
or Rc<dyn Fn...>
) in a generic context.
Required Associated Types§
Required Methods§
fn new<'a, A: 'a, B: 'a>( f: impl 'a + Fn(A) -> B, ) -> <Self as ClonableFn>::Output<'a, 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.