🚧 temp save

This commit is contained in:
laazy 2024-03-23 14:10:41 +08:00
parent 645c24ceba
commit 9099bdcea5
2 changed files with 9 additions and 7 deletions

View File

@ -21,19 +21,18 @@
// //
// Execute `rustlings hint arc1` or use the `hint` watch subcommand for a hint. // 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. #![forbid(unused_imports)] // Do not change this, (or the next) line.
use std::sync::Arc; use std::sync::Arc;
use std::thread; use std::thread;
fn main() { fn main() {
let numbers: Vec<_> = (0..100u32).collect(); let numbers: Vec<_> = (0..100u32).collect();
let shared_numbers = // TODO let shared_numbers = Arc::new(numbers);
// numbers.iter().sum();
let mut joinhandles = Vec::new(); let mut joinhandles = Vec::new();
for offset in 0..8 { for offset in 0..8 {
let child_numbers = // TODO let child_numbers = Arc::clone(&shared_numbers);
joinhandles.push(thread::spawn(move || { joinhandles.push(thread::spawn(move || {
let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum(); let sum: u32 = child_numbers.iter().filter(|&&n| n % 8 == offset).sum();
println!("Sum of offset {} is {}", offset, sum); println!("Sum of offset {} is {}", offset, sum);

View File

@ -48,7 +48,8 @@ mod tests {
let slice = [0, 1, 2]; let slice = [0, 1, 2];
let mut input = Cow::from(&slice[..]); let mut input = Cow::from(&slice[..]);
match abs_all(&mut input) { 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 slice = vec![0, 1, 2];
let mut input = Cow::from(slice); let mut input = Cow::from(slice);
match abs_all(&mut input) { 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 slice = vec![-1, 0, 1];
let mut input = Cow::from(slice); let mut input = Cow::from(slice);
match abs_all(&mut input) { match abs_all(&mut input) {
// TODO Cow::Owned(_) => Ok(()),
Cow::Borrowed(_) => Err(""),
} }
} }
} }