Trait orx_closure::FunOptRef
source · pub trait FunOptRef<In, Out: ?Sized> {
// Required method
fn call(&self, input: In) -> Option<&Out>;
}Expand description
Function trait representing In -> Option<&Out> transformation.
It provides the common interface for closures, such as ClosureOptRef<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 FunOptRef<In, Out> trait object.
Relation with Fn
FunOptRef<In, Out> can be considered equivalent to Fn(In) -> Option<&Out>.
However, it appears to be impossible to have an instance of the latter due to lifetime errors.
Therefore, FunOptRef<In, Out> is required.