Skip to content

Instantly share code, notes, and snippets.

@spikegrobstein
Created July 25, 2019 23:50
Show Gist options
  • Save spikegrobstein/462dbf5f82ac1b3cfa638ef32ff5559f to your computer and use it in GitHub Desktop.
Save spikegrobstein/462dbf5f82ac1b3cfa638ef32ff5559f to your computer and use it in GitHub Desktop.
fn sum(x: Vec<u32>) -> u32 {
x.iter().fold(0, |acc, i| acc + i)
}
fn main() {
let my_vec: Vec<u32> = vec![ 1, 2, 3 ];
println!("sum: {}", sum(my_vec));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment