Vector methods
Vectors
-
for vector of chars = String.chars().collect()
Just String.chars() will be dependent on the previous string. It cant be used if the string gets dropped.
collect() is particularly useful while scanning.
-
Map func: (transforms iterator, implements [FnMut])
let a = [1,2,3]; println!("{:#?}",a.map(|x| 2*x));
But map () is lazy , ex:
a.map(|x| println!(x))
wont work. -
Fold func: Folds every element into an accumulator.
let a = [1,2,3] let sum = a.iter().fold(0,|acc,x| acc+x);