diff --git a/standard_library_types/arc1.rs b/standard_library_types/arc1.rs new file mode 100644 index 0000000..f86f721 --- /dev/null +++ b/standard_library_types/arc1.rs @@ -0,0 +1,52 @@ +// make this code compile and don't create any copies of the "numbers" Vec. +// scroll down for hints + +use std::sync::Arc; +use std::thread; + +fn main() { + let numbers: Vec<_> = (0..100u32).collect(); + let shared_numbers = // TODO + let mut joinhandles = Vec::new(); + + for offset in 0..5 { + joinhandles.push( + thread::spawn(move || { + let mut i = offset; + let mut sum = 0; + while i