[][src]Trait recur_fn::RecurFn

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

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

The trait representing a recursive function.

Instead of recurring directly, this trait uses an injection parameter for recursion, as you can see in body method.

Note that the implementation of this trait may not really recur, i.e. the body method may not call recur parameter. In fact, all implementation of Fn(Arg) -> Output implements RecurFn<Arg, Output>.

This trait only supports one argument. If you want to have multiple arguments, use tuple.

Required methods

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

The body of the recursive function.

Loading content...

Provided methods

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

Calls the recursive function.

Loading content...

Implementors

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

Implement RecurFn<Arg, Output> for the normal function Fn(Arg) -> Output. The implementation calls the function directly, without calling recur.

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

Loading content...