Skip to content

Commit 9d17850

Browse files
04091948
1 parent 749e59c commit 9d17850

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

exercises/smart_pointers/arc1.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,17 @@
2121
//
2222
// Execute `rustlings hint arc1` or use the `hint` watch subcommand for a hint.
2323

24-
// I AM NOT DONE
25-
2624
#![forbid(unused_imports)] // Do not change this, (or the next) line.
2725
use std::sync::Arc;
2826
use std::thread;
2927

3028
fn main() {
3129
let numbers: Vec<_> = (0..100u32).collect();
32-
let shared_numbers = // TODO
30+
let shared_numbers = Arc::new(numbers);
3331
let mut joinhandles = Vec::new();
3432

3533
for offset in 0..8 {
36-
let child_numbers = // TODO
34+
let child_numbers = Arc::clone(&shared_numbers);
3735
joinhandles.push(thread::spawn(move || {
3836
let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
3937
println!("Sum of offset {} is {}", offset, sum);

0 commit comments

Comments
 (0)