Feature Request: NonZeroInt literal coersion #69329
Labels
A-coercions
Area: implicit and explicit `expr as Type` coercions
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
It should be possible for an integer literal to initialize a
NonZeroInt
type, likeNonZeroUsize
. For instance, this should be legal:The compiler can easily check whether the literal is zero and fail if it is.
While I know that the
NonZero
types are "just" regular structs, it seems as though they already have so many special compiler attributes attached to them to ensure that they work with Option correctly that it seems like it wouldn't be much of a stretch to have this one as well (though I'm happy to be corrected there).The text was updated successfully, but these errors were encountered: