Why is the NonZeroUsize::new_unchecked method marked as unsafe? If I understand correctly, the
unsafe keyword is reserved for methods/functions that can lead directly or indirectly to undefined behavior (UB).
But I fail to see how the
unsafe status of
NonZeroUsize::new_unchecked is relevant since all its methods are safe, and, as such, are not guaranteed to actually return a non-zero value. In other words, unsafe code cannot trust the
NonZeroUsize::get method (and should perform a non-zero test) because it is not itself unsafe (as explained in the nomicon).