this post was submitted on 16 Sep 2024
53 points (100.0% liked)
Rust
5960 readers
7 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Best practice when using
.unwrap()
in production code is to put a line of documentation immediately above the use of.unwrap()
that describes the safety invariants which allow the unwrap to be safe.Since code churn could eventually cause those safety invariants to be violated, I think it's not a bad thing for a blunt audit of
.unwrap()
to bring your attention to those cases and prompt to reevaluate if the invariants are still satisfied.