[][src]Trait recur_fn::RecurFn

pub trait RecurFn<Arg, Output> {
    fn body(&self, recur: impl Fn(Arg) -> Output, arg: Arg) -> Output;

    fn call(&self, arg: Arg) -> Output { ... }
}

The recursive function trait.

Instead of recurring directly, this trait allows user to customize the recursion. In this way, we can extract and extend the body of a recursive function.

This trait supports only one argument. If you need multiple arguments, use tuple.

Required methods

fn body(&self, recur: impl Fn(Arg) -> Output, arg: Arg) -> Output

The body of the recursive function.

Marking this method by #[inline] will make the call method as fast as recurring directly.

Loading content...

Provided methods

fn call(&self, arg: Arg) -> Output

Calls the recursive function.

Loading content...

Implementors

impl<'a, Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + 'a[src]

impl<'a, Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Send + 'a[src]

impl<'a, Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Send + Sync + 'a[src]

impl<'a, Arg, Output> RecurFn<Arg, Output> for dyn DynRecurFn<Arg, Output> + Sync + 'a[src]

impl<Arg, Output, D> RecurFn<Arg, Output> for FromPointer<D> where
    D: Deref,
    D::Target: RecurFn<Arg, Output>, 
[src]

impl<Arg, Output, F> RecurFn<Arg, Output> for Closure<F> where
    F: Fn(&dyn Fn(Arg) -> Output, Arg) -> Output, 
[src]

impl<Arg, Output, F> RecurFn<Arg, Output> for Direct<F> where
    F: Fn(Arg) -> Output, 
[src]

Loading content...