[][src]Macro recur_fn::as_recur_fn

macro_rules! as_recur_fn {
    ($fn_name:ident ($arg_name:ident: $arg_type:ty) -> $output_type:ty $body:block) => { ... };
}

Constructs a zero-cost RecurFn implementation that doesn't capture.

You can consider it as a function definition, except fn keyword is replaced by this macro.

So it's recommended to first write function definition and then change it into this macro, so that the IDE's features can work while you're coding the function's body.

Examples

use recur_fn::{as_recur_fn, RecurFn};

let fact = as_recur_fn!(fact(n: u64) -> u64 {
    if n == 0 { 1 } else { n * fact(n - 1) }
});
assert_eq!(6, fact.call(3));
assert_eq!(0,
    fact.body(|_| 0, 3));