MCPcopy Create free account
hub / github.com/QMHTMY/RustBook / sum_of_val2

Function sum_of_val2

code/chapter01/rust_basic.rs:12–14  ·  view source on GitHub ↗

优化版

(nums: &[i32], num: i32)

Source from the content-addressed store, hash-verified

10
11// 优化版
12fn sum_of_val2(nums: &[i32], num: i32) -> i32 {
13 nums.iter().sum::<i32>() + num
14}
15
16fn main() {
17 let num = 10;

Callers

nothing calls this directly

Calls 1

iterMethod · 0.45

Tested by

no test coverage detected