You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I managed to get
✓ Successfully ran exercises/standard_library_types/arc1.rs!
which followed the letter of the exercise:
// Make this code compile by filling in a value for shared_numbers where the
// TODO comment is and create an initial binding for child_numbers somewhere.
// Try not to create any copies of the numbers Vec!
but failed the spirit of the exercise, (and ignored the hint - [flawed logic://{but why would I need the hint if I've already passed the exercise?}])
SPOILER: bad code, that compiles
use std::sync::Arc;use std::thread;fnmain(){let numbers:Vec<_> = (0..100u32).collect();let shared_numbers = [12,17,9];letmut joinhandles = Vec::new();for offset in0..8{
joinhandles.push(thread::spawn(move || {letmut i = offset;letmut sum = 0;//let child_numbers: Vec<u32> = [0; 100].to_vec(); // This is enough to compile, but circumvents the exercise of using Arclet child_numbers:Vec<_> = (0..100u32).collect();// Same as previous line, but with valueswhile i < child_numbers.len(){
sum += child_numbers[i];
i += 5;}println!("Sum of offset {} is {}", offset, sum);}));}for handle in joinhandles.into_iter(){
handle.join().unwrap();}}
The use std::sync::Arc; and filename of arc1.rs should be enough of a clue, but would it be helpful for rustlings to check that the topic being taught is actually being applied? (In this case, check that something is wrapped in an Arc?) Or at least have a soft, "// Must use std::sync::Arc;" added to the head of the file.
(Would the following be helpful, or too much?)
// I AM NOT DONE#![forbid(unused_imports)]//Do not remove this, (or the next) line.use std::sync::Arc;
The text was updated successfully, but these errors were encountered:
I managed to get
✓ Successfully ran exercises/standard_library_types/arc1.rs!
which followed the letter of the exercise:
// Make this code compile by filling in a value for
shared_numbers
where the// TODO comment is and create an initial binding for
child_numbers
somewhere.// Try not to create any copies of the
numbers
Vec!but failed the spirit of the exercise, (and ignored the hint - [flawed logic://{but why would I need the hint if I've already passed the exercise?}])
SPOILER: bad code, that compiles
The
use std::sync::Arc;
and filename of arc1.rs should be enough of a clue, but would it be helpful for rustlings to check that the topic being taught is actually being applied? (In this case, check that something is wrapped in an Arc?) Or at least have a soft, "// Must use std::sync::Arc;" added to the head of the file.(Would the following be helpful, or too much?)
The text was updated successfully, but these errors were encountered: