-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Proposal
Stabilize core::num::ZeroablePrimitive, keeping it sealed (and unsafe).
Problem statement
Since Rust 1.79, core::num::NonZero<T> is stable for T: ZeroablePrimitive. Yet, since ZeroablePrimitive is unstable, it is impossible to write generic code over NonZero.
Motivating examples or use cases
easy_cast::Cast supports numeric type conversions, a little like Into and TryInto but with different semantics. It has been requested that this support NonZero types.
The implementation of this should be fairly simple: kas-gui/easy-cast#36
Alternatives
Every "generic impl" over NonZero must instead be non-generic, likely repeated for a number of types or combinations of types using macro_rules!. The implementation of easy_cast::Conv over primitive integer types uses 29 invocations of macros, many of them recursive (covering 12 × 11 = 132 combinations IIRC).
Links and related work
Tracking issue for NonZero: rust-lang/rust#120257