Created
November 12, 2015 19:47
-
-
Save blippy/e93bef3fbfa54756a8ea to your computer and use it in GitHub Desktop.
Sum a vector using references
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn summit(vec:&Vec<i64>) -> i64 | |
{ | |
let mut sum = 0i64; | |
for x in vec { sum = sum + x }; | |
return sum; | |
} | |
fn main() | |
{ | |
let vec = vec![10i64, 11, 12]; | |
println!("{}", summit(&vec)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment