Closed
Description
https://rust.godbolt.org/z/eTPzE6
Technically, NonZero* types are not meant to be used for optimizing arithmetic, but people (like myself) may or may not know that or may assume otherwise.
It is possible to create a NonZero* object with 0 inner value, but since that is a misuse of the type and deliberate violation of the safety guarantees, I think it would make sense to teach the compiler that get()
can't return 0.
Edit: unfortunately, since NonZero* methods are const, it's not as simple as adding an assume.
Metadata
Metadata
Assignees
Labels
No labels