Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created August 23, 2014 02:59
Show Gist options
  • Save JEG2/6852e8d5c505c724025d to your computer and use it in GitHub Desktop.
Save JEG2/6852e8d5c505c724025d to your computer and use it in GitHub Desktop.
Incrementing a list of numbers without mut.
fn increment(numbers: &Vec<int>) -> Vec<int> {
numbers.iter().map(|n| n + 1).collect()
}
fn main() {
let before = vec![1i, 2, 3];
let after = increment(&before);
println!("{}", after);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment