MCPcopy Create free account
hub / github.com/CleanCut/ultimate_rust2 / expensive_sum

Function expensive_sum

exercise/threads_channels/src/main.rs:11–16  ·  view source on GitHub ↗
(v: Vec<i32>)

Source from the content-addressed store, hash-verified

9}
10
11fn expensive_sum(v: Vec<i32>) -> i32 {
12 // Pretend our fancy little filter-map-sum is expensive and takes 500ms
13 sleep_ms(500);
14 println!("Child thread: just about finished");
15 v.iter().filter(|&x| x % 2 == 0).map(|x| x * x).sum()
16}
17
18fn main() {
19 let my_vector = vec![2, 5, 1, 0, 4, 3];

Callers

nothing calls this directly

Calls 1

sleep_msFunction · 0.85

Tested by

no test coverage detected