pub trait HasNonZero: Sized {
type NonZero: Copy;
// Required methods
fn into_nonzero(self) -> Option<Self::NonZero>;
fn nonzero_get(nz: Self::NonZero) -> Self;
}Expand description
Bridge to core::num::NonZero — “the non-zero form of Self”.
This does not duplicate core::num::NonZero: for the integer primitives
NonZero is core::num::NonZero<Self>, with its real
niche. (core::num::NonZero<T> is sealed to primitives, so a future bignum
backend supplies its own non-zero type as the associated type instead.)
The value is recovered through the crate-owned const accessor
nonzero_get rather than an Into<Self> bound:
From<NonZero<T>> for T is not const, so such a bound would poison every
generic const consumer.
Required Associated Types§
Required Methods§
Sourcefn into_nonzero(self) -> Option<Self::NonZero>
fn into_nonzero(self) -> Option<Self::NonZero>
Some iff self != 0.
Sourcefn nonzero_get(nz: Self::NonZero) -> Self
fn nonzero_get(nz: Self::NonZero) -> Self
Recover the underlying value from its non-zero form.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".