Post #2227744
2025-11-19 11:45 UTC
@azymohliad@fosstodon.org @zimzat@mastodon.social I use `getOrPanic`, along with this naming scheme, which –unlike Rust's– is internally consistent:
https://soc.me/languages/naming-conventions-option-and-result
Replies (1)
-
@azymohliad@fosstodon.org 2025-11-19 17:01
@soc@chaos.social I like it! @Mara@hachyderm.io could this actually be a solution for Rust 1.X? All existing .unwrap_*() could be renamed to .get_*(), .unwrap() would become .get_or_panic(), .expect() would be .get_or_panic_with(), Result::unwrap_err() would become .get_err_or_panic(), and it all seems to align well with the existing Option::get_or_insert*(). .unwrap() name would become longer, but maybe it's actually not a bad thing to "increase the price" of panicking? Other `unwrap_*` methods would become shorter!