[][src]Function unfold::unfold_nth

pub fn unfold_nth<T, F>(func: F, init: T, index: usize) -> T where
    F: Fn(T) -> T,
    T: Copy

This function create an unfold iterator and returns its index-th item.

use unfold::unfold_nth;

let n = unfold_nth(|x| x + 1, 0, 10);
assert_eq!(n, 9);