Skip to content

threads2: Assert jobs_done == 10 to reject non-shared solutions (#2200) - #2454

Open
GolakiyaVishal wants to merge 3 commits into
rust-lang:mainfrom
GolakiyaVishal:main
Open

GolakiyaVishal wants to merge 3 commits into
rust-lang:mainfrom
GolakiyaVishal:main

Conversation

@GolakiyaVishal

@GolakiyaVishal GolakiyaVishal commented Sep 24, 2026 •

Copy link
Copy Markdown

Fixes #2200

Problem

threads2 is configured with test = false, same as other exercises. So Rustlings only checks that the exercise compile and runs. There for user able to complete it many ways.

Changes

  • Now computes jobs_done as a variable instead of inclining it in println!.
  • Added assert_eq! at the end of main so it actually check the jobs_done. So if the shared state not change then it will panic and exercise fails.
  • Updated solutions/20_threads/threads2.rs to match the new structure.

Testing

  • The official Arc<Mutex<JobStatus>> solution passes.
  • The Arc::make_mut approach from the issue now fails with the assertion message.
  • cargo run -- dev check passes.

@GolakiyaVishal
GolakiyaVishal marked this pull request as ready for review September 25, 2026 05:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Threads2 wrong solution possible

1 participant