Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually protect against deadlock in Dining Philosophers async exerci…
…se (google#1772) Swapping forks for one philosopher feels like cheating. It's like one of the philosophers is facing away from the table. Or perhaps it's the only right-handed philosopher at the table. More importantly, there is no effective mechanism to prevent deadlocks. Add that mechanism, it's useful for learning Rust. The new code demonstrates let-else, drop and returning values from a loop. `std::mem::swap` remains in the thread version of the Dining Philosophers exercise for now. This also fixes compilation. `left_fork` and `right_fork` had to be `mut` in `main()` for the workaround to compile.
- Loading branch information