mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-03 01:09:18 +00:00
🚧 temp save
This commit is contained in:
parent
645c24ceba
commit
9099bdcea5
@ -21,19 +21,18 @@
|
||||
//
|
||||
// Execute `rustlings hint arc1` or use the `hint` watch subcommand for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
#![forbid(unused_imports)] // Do not change this, (or the next) line.
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let numbers: Vec<_> = (0..100u32).collect();
|
||||
let shared_numbers = // TODO
|
||||
let shared_numbers = Arc::new(numbers);
|
||||
// numbers.iter().sum();
|
||||
let mut joinhandles = Vec::new();
|
||||
|
||||
for offset in 0..8 {
|
||||
let child_numbers = // TODO
|
||||
let child_numbers = Arc::clone(&shared_numbers);
|
||||
joinhandles.push(thread::spawn(move || {
|
||||
let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
|
||||
println!("Sum of offset {} is {}", offset, sum);
|
||||
|
||||
@ -48,7 +48,8 @@ mod tests {
|
||||
let slice = [0, 1, 2];
|
||||
let mut input = Cow::from(&slice[..]);
|
||||
match abs_all(&mut input) {
|
||||
// TODO
|
||||
Cow::Borrowed(_) => Ok(()),
|
||||
Cow::Owned(_) => Err("Expect"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +61,8 @@ mod tests {
|
||||
let slice = vec![0, 1, 2];
|
||||
let mut input = Cow::from(slice);
|
||||
match abs_all(&mut input) {
|
||||
// TODO
|
||||
Cow::Owned(_) => Ok(()),
|
||||
Cow::Borrowed(_) => Err("Expected owned value"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +74,8 @@ mod tests {
|
||||
let slice = vec![-1, 0, 1];
|
||||
let mut input = Cow::from(slice);
|
||||
match abs_all(&mut input) {
|
||||
// TODO
|
||||
Cow::Owned(_) => Ok(()),
|
||||
Cow::Borrowed(_) => Err(""),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user