Guest User

Untitled

a guest
Jun 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. fn main() {
  2. let a = [1, 2, 3];
  3.  
  4. // the checked sum of all of the elements of the array
  5. let sum = a.iter().try_fold(0i8, |acc, &x| acc.checked_add(x));
  6.  
  7. assert_eq!(sum, Some(6));
  8. }
Add Comment
Please, Sign In to add comment