Programming-Idioms

History of Idiom 54 > diff from v26 to v27

Edit summary for version 27 :
New Rust implementation by user [freecoder]

Version 26

2017-06-14, 15:10:53

Version 27

2018-12-17, 17:55:45

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Code
let s = x.iter().sum::<i32>();
Doc URL
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.sum
Demo URL
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=5f8d42f26371a1e805b7b3a96875837e