Iterator consumer. Allows the accumulated value to be arbitrary type. Note the different types.
1
2
3
let nums: Vec<u8> = vec![1, 2, 3, 4];
let sum = nums.iter().fold(0u32, |acc, x| acc + *x as u32);
assert_eq!(sum, 10);
Iterator consumer. Allows the accumulated value to be arbitrary type. Note the different types.
1
2
3
let nums: Vec<u8> = vec![1, 2, 3, 4];
let sum = nums.iter().fold(0u32, |acc, x| acc + *x as u32);
assert_eq!(sum, 10);
A new version of content is available.