Question : rust sum vector
Answered by : zakhar-starinski
// still waiting for grepper to add rust syntax highlighting
fn main() { let v = vec![1, 2, 3, 4, 5]; let sum: u8 = a.iter().sum(); println!("the total sum is: {}", sum); // the total sum is: 15
}
Source : https://stackoverflow.com/questions/23100534/how-to-sum-the-values-in-an-array-slice-or-vec-in-rust | Last Update : Mon, 07 Jun 21