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.