I have unwraps in my code that are safe to do and I use comments to indicate why it is okay to unwrap. However, I was wondering if there is a way (maybe extending clippy for e.g) or other approaches that folx have used to detect unwraps in the code that don't include an explanation. Thanks!
No, if that would be enforced, that would likely break a fair amount of code.
However, there are {Result, Option}::expect()
which may fit your needs.
2 Likes
And you can even enforce always using expect
instead of unwrap
with #![deny(clippy::unwrap_used)]
.
3 Likes
Thank you for the tips!