4 ms·
Looks like an expect there would be an improvement. Do you write that line often enough that adding an error message is a problem?
by marcosdumay 4y ago
Looks like an expect there would be an improvement. Do you write that line often enough that adding an error message is a problem?
- assbuttbuttass 4y agoThe reason I would hesitate to replace this with an expect is that I really don't ever expect .lock() to fail, so .expect just adds verbosity for no benefit. The article talks about the Regex::new method, which has much the same problem. For the majority of use cases, you don't expect it to ever fail. Maybe Mutex could introduce a new method .lock_or_die, because it's such a common pattern
- Matthias247 4y agoThere's not really a benefit to "except", since the stacktrace you get on the panic tells you exactly what happened (Mutex was poisoned). Repeating that in a custom error string doesn't make the behavior much better.