[][src]Function unfold::unfold_vector

pub fn unfold_vector<T, F>(func: F, init: T, len: usize) -> Vec<T> where
    F: Fn(T) -> T,
    T: Copy

This function create an unfold iterator and collects its first len items into a vector

use unfold::unfold_vector;
 
let exp_growth = unfold_vector(|x| 2 * x, 1, 10);
 
assert_eq!(exp_growth, vec![1, 2, 4, 8, 16, 32, 64, 128, 256, 512]);