Trait FunRef

Source
pub trait FunRef<In, Out: ?Sized> {
    // Required method
    fn call(&self, input: In) -> &Out;
}
Expand description

Function trait representing In -> &Out transformation.

It provides the common interface for closures, such as ClosureRef<Capture, In, Out>, over all capture types.

Furthermore, this trait enables to forget about the capture, or equivalently drop the Capture generic parameter, by using dyn FunRef<In, Out> trait object.

§Relation with Fn

FunRef<In, Out> can be considered equivalent to Fn(In) -> &Out.

However, it appears to be impossible to have an instance of the latter due to lifetime errors. Therefore, FunRef<In, Out> is required.

Required Methods§

Source

fn call(&self, input: In) -> &Out

Calls the function with the given input and returns the produced output.

Implementors§

Source§

impl<C1, C2, C3, C4, In, Out: ?Sized> FunRef<In, Out> for ClosureRefOneOf4<C1, C2, C3, C4, In, Out>

Source§

impl<C1, C2, C3, In, Out: ?Sized> FunRef<In, Out> for ClosureRefOneOf3<C1, C2, C3, In, Out>

Source§

impl<C1, C2, In, Out: ?Sized> FunRef<In, Out> for ClosureRefOneOf2<C1, C2, In, Out>

Source§

impl<Capture, In, Out: ?Sized> FunRef<In, Out> for ClosureRef<Capture, In, Out>