We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 749e59c commit 9d17850Copy full SHA for 9d17850
exercises/smart_pointers/arc1.rs
@@ -21,19 +21,17 @@
21
//
22
// Execute `rustlings hint arc1` or use the `hint` watch subcommand for a hint.
23
24
-// I AM NOT DONE
25
-
26
#![forbid(unused_imports)] // Do not change this, (or the next) line.
27
use std::sync::Arc;
28
use std::thread;
29
30
fn main() {
31
let numbers: Vec<_> = (0..100u32).collect();
32
- let shared_numbers = // TODO
+ let shared_numbers = Arc::new(numbers);
33
let mut joinhandles = Vec::new();
34
35
for offset in 0..8 {
36
- let child_numbers = // TODO
+ let child_numbers = Arc::clone(&shared_numbers);
37
joinhandles.push(thread::spawn(move || {
38
let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
39
println!("Sum of offset {} is {}", offset, sum);
0 commit comments