Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
// 优化版
12
fn sum_of_val2(nums: &[i32], num: i32) -> i32 {
13
nums.iter().sum::<i32>() + num
14
}
15
16
fn main() {
17
let num = 10;
Callers
nothing calls this directly
Calls
1
iter
Method · 0.45
Tested by
no test coverage detected