[][src]Trait recur_fn::RecurFn

pub trait RecurFn<Arg, Output> {
    fn body<Recur: Fn(Arg) -> Output>(&self, recur: Recur, 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 by accepting Fn-type parameter. In this way, we can extract or extend the body of the recursive function.

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

Required methods

fn body<Recur: Fn(Arg) -> Output>(&self, recur: Recur, 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.

Loading content...

Provided methods

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

Call the recursive function.

Loading content...

Implementors

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

Implements RecurFn<Arg, Output> for Fn(Arg) -> Output. It calls the function directly, without calling recur parameter.

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

Loading content...