[−][src]Trait recur_fn::RecurFn
The recursive function trait.
Instead of recurring directly,
this trait allows user to customize the recursion
by accepting Fn
-type parameter.
In this way, we can extract and extend the body of the recursive function.
This trait only supports one argument. If you need multiple arguments, use tuple.
Required methods
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
The body of the recursive function.
Performance tip: mark this method #[inline]
to make the
call
method as fast as recurring directly.
Provided methods
fn call(&self, arg: Arg) -> Output
Calls the recursive function.
Implementors
impl<Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output>
[src]
dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Send
[src]
dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Send + Sync
[src]
dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Sync
[src]
dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output, '_> RecurFn<Arg, Output> for &'_ (dyn DynRecurFn<Arg, Output> + Send + Sync)
[src]
&dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output, '_> RecurFn<Arg, Output> for &'_ (dyn DynRecurFn<Arg, Output> + Send)
[src]
&dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output, '_> RecurFn<Arg, Output> for &'_ (dyn DynRecurFn<Arg, Output> + Sync)
[src]
&dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output, '_> RecurFn<Arg, Output> for &'_ dyn DynRecurFn<Arg, Output>
[src]
&dyn DynRecurFn
implement RecurFn
.
fn body(
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
[src]
&self,
recur: impl Fn(Arg) -> Output,
arg: Arg
) -> Output
fn call(&self, arg: Arg) -> Output
[src]
impl<Arg, Output, F: Fn(Arg) -> Output> RecurFn<Arg, Output> for F
[src]
Fn(Arg) -> Output
s implement RecurFn<Arg, Output>
.
It calls the function directly, without calling recur
parameter.