Files
compiler-explorer/examples/rust/Sum_over_array.rs
Christopher Serr 91a35e65d4 Improve the Rust examples
This commit
 - formats the Rust examples idiomatically
 - uses idiomatic code
 - uses only safe code without compromising on performance
 - makes them compile on stable
2020-03-26 23:28:49 +01:00

4 lines
66 B
Rust

pub fn sum_array(input: &[i32]) -> i32 {
input.iter().sum()
}