std::num::NonZeroUsize does not implement the trait std::convert::TryFrom<usize>, and the same goes for all the other NonZero types - they don't implement TryFrom conversions from their inner type. This seems to be exactly the sort of situation that TryFrom was created for, so they probably should.
The NonZeroUsize::new() method already does something similar by returning None if the value is zero, but having TryFrom would be nice for consistency and for generic code.
std::num::NonZeroUsizedoes not implement the traitstd::convert::TryFrom<usize>, and the same goes for all the otherNonZerotypes - they don't implementTryFromconversions from their inner type. This seems to be exactly the sort of situation thatTryFromwas created for, so they probably should.The
NonZeroUsize::new()method already does something similar by returningNoneif the value is zero, but havingTryFromwould be nice for consistency and for generic code.