NonZeroUsize should implement TryFrom<usize> #73664
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
std::num::NonZeroUsize
does not implement the traitstd::convert::TryFrom<usize>
, and the same goes for all the otherNonZero
types - they don't implementTryFrom
conversions from their inner type. This seems to be exactly the sort of situation thatTryFrom
was created for, so they probably should.The
NonZeroUsize::new()
method already does something similar by returningNone
if the value is zero, but havingTryFrom
would be nice for consistency and for generic code.The text was updated successfully, but these errors were encountered: