Type Alias NonZeroI128
type NonZeroI128 = NonZero<i128>
An i128 that is known not to equal zero.
This enables some memory layout optimization.
For example, Option<NonZeroI128> is the same size as i128:
assert_eq!;
Layout
NonZeroI128 is guaranteed to have the same layout and bit validity as i128
with the exception that 0 is not a valid instance.
Option<NonZeroI128> is guaranteed to be compatible with i128,
including in FFI.
Thanks to the null pointer optimization,
NonZeroI128 and Option<NonZeroI128>
are guaranteed to have the same size and alignment:
use NonZeroI128;
assert_eq!;
assert_eq!;
Compile-time creation
Since both [Option::unwrap()] and [Option::expect()] are const, it is possible to
define a new
NonZeroI128
at compile time via:
use NonZeroI128;
const TEN: NonZeroI128 = new.expect;