Further thoughts:
Deadlocks and other problems should be avoided per-design. As in not exposing the lock directly and just having functions to access and update the state. For example instead of getting a mutable reference to the current stats we should allow add/sub stats:
state.sub_stats(CharStats {
hp: 50,
mp: 5,
..Default::default()
});
instead of exposing the lock and doing It by hand:
state.lock().hp -= 50;
state.lock().mp -= 5;
Which is also prone to overflows.
Further thoughts:
Deadlocks and other problems should be avoided per-design. As in not exposing the lock directly and just having functions to access and update the state. For example instead of getting a mutable reference to the current stats we should allow add/sub stats:
instead of exposing the lock and doing It by hand:
Which is also prone to overflows.