Onelinerhub / onelinerhub

Thousands of code solutions with clear explanation @ onelinerhub.com
https://onelinerhub.com
MIT License
810 stars 161 forks source link

"How to join a thread with a timeout in Rust?" is not valid Rust #2001

Open Chasethechicken opened 10 months ago

Chasethechicken commented 10 months ago
  1. A link to the code with a problem: https://onelinerhub.com/rust/how-to-join-a-thread-with-a-timeout-in-rust
  2. Short explanation of the problem in the solution The code explains, that join_timeout can be used to join a thread with a timeout. This is false, as can be seen in the linked docs: https://doc.rust-lang.org/std/thread/struct.Thread.html#method.join_timeout and additionally https://doc.rust-lang.org/std/thread/struct.JoinHandle.html A JoinHandle has no function join_timeout.
  3. Proposal of changes (if any): Remove the example. Alternatively implement something using is_finished instead, to check if the thread has finished.