As simple as it sounds. You have a function, you want to create an infinite iterable that repeatedly calls said function over and over? This package is for you
If you have a function, just pass it to the from
function of the package.
You can use take to get a specified number of elements.
```Rust extern crate iterfromfn;
fn generate_one() -> u64 { 1 }
asserteq!(
vec![1; 10],
iterfromfn::rom(generateone).take(10).collect::
let mut x = 0;
let closure = || { x += 1; x }
asserteq!(
vec![1,2,3,4,5],
iterfrom_fn::from(closure).take(5).collect::
You can also use it in a for loop and break
```Rust extern crate iterfromfn;
let mut x = 1; let closure = || { let temp = x;
//x = (x + 1)^2 each iteration x += 1; x *= x;
temp };
let mut v = Vec::new(); for x in iterfromfn::from(closure) { if x >= 10 { break }
v.push(x); }
assert_eq!(vec![1, 4], v); ```
Use a closure if you need to bind values to arguments.
```Rust extern crate iterfromfn;
let vec100capacity = || Vec::withcapacity(100); let mut it = iterfromfn::from(vec100_capacity);
assert_eq!(100, it.next().capacity()); ```