From 0842bd26b1872f665bdb9221e84bac1b50501f1f Mon Sep 17 00:00:00 2001 From: goVishal Date: Thu, 24 Sep 2026 21:17:33 +0530 Subject: [PATCH 1/3] threads2: Assert jobs_done == 10 to reject non-shared solutions (#2200) --- exercises/20_threads/threads2.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exercises/20_threads/threads2.rs b/exercises/20_threads/threads2.rs index 7020cb9cea..ec6410b57a 100644 --- a/exercises/20_threads/threads2.rs +++ b/exercises/20_threads/threads2.rs @@ -30,5 +30,8 @@ fn main() { } // TODO: Print the value of `JobStatus.jobs_done`. - println!("Jobs done: {}", todo!()); + let jobs_done: u32 = todo!(); + println!("Jobs done: {}", jobs_done); + + assert_eq!(jobs_done, 10, "All 10 threads must update the *shared* status"); } From 80d4582389ef41525877adcfd67d4216017f5d14 Mon Sep 17 00:00:00 2001 From: goVishal Date: Thu, 24 Sep 2026 21:42:54 +0530 Subject: [PATCH 2/3] threads2: solution updated according to updated exercise. --- solutions/20_threads/threads2.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/solutions/20_threads/threads2.rs b/solutions/20_threads/threads2.rs index bc268d63f6..3302e662a7 100644 --- a/solutions/20_threads/threads2.rs +++ b/solutions/20_threads/threads2.rs @@ -36,6 +36,9 @@ fn main() { handle.join().unwrap(); } - println!("Jobs done: {}", status.lock().unwrap().jobs_done); - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + let jobs_done: u32 = status.lock().unwrap().jobs_done; + // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + println!("Jobs done: {}", jobs_done); + + assert_eq!(jobs_done, 10, "All 10 threads must update the *shared* status"); } From 3b574cf945bbb61c7069f532f33eaae56a38c712 Mon Sep 17 00:00:00 2001 From: goVishal Date: Fri, 25 Sep 2026 11:04:50 +0530 Subject: [PATCH 3/3] format assert_eq! for better readability with rustfmt --- solutions/20_threads/threads2.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/solutions/20_threads/threads2.rs b/solutions/20_threads/threads2.rs index 3302e662a7..f70e21788e 100644 --- a/solutions/20_threads/threads2.rs +++ b/solutions/20_threads/threads2.rs @@ -40,5 +40,8 @@ fn main() { // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ println!("Jobs done: {}", jobs_done); - assert_eq!(jobs_done, 10, "All 10 threads must update the *shared* status"); + assert_eq!( + jobs_done, 10, + "All 10 threads must update the *shared* status" + ); }