Skip to main content

ZeroablePrimitive

Trait ZeroablePrimitive 

Source
pub unsafe trait ZeroablePrimitive: Sized + Copy {
    type NonZeroInner: Copy;
}
This trait cannot be implemented outside core.
🔬This is a nightly-only experimental API. (nonzero_internals)
Expand description

A marker trait for primitive types which can be zero.

This is an implementation detail for NonZero<T> which may disappear or be replaced at any time.

§Safety

Types implementing this trait must be primitives that are valid when zeroed.

The associated Self::NonZeroInner type must have the same size+align as Self, but with a niche and bit validity making it so the following transmutes are sound:

  • Self::NonZeroInner to Option<Self::NonZeroInner>
  • Option<Self::NonZeroInner> to Self

(And, consequently, Self::NonZeroInner to Self.)

Required Associated Types§

Source

type NonZeroInner: Copy

🔬This is a nightly-only experimental API. (nonzero_internals)

A type like Self but with a niche that includes zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ZeroablePrimitive for char

Source§

type NonZeroInner = NonZeroCharInner

Source§

impl ZeroablePrimitive for i8

Source§

type NonZeroInner = NonZeroI8Inner

Source§

impl ZeroablePrimitive for i16

Source§

type NonZeroInner = NonZeroI16Inner

Source§

impl ZeroablePrimitive for i32

Source§

type NonZeroInner = NonZeroI32Inner

Source§

impl ZeroablePrimitive for i64

Source§

type NonZeroInner = NonZeroI64Inner

Source§

impl ZeroablePrimitive for i128

Source§

type NonZeroInner = NonZeroI128Inner

Source§

impl ZeroablePrimitive for isize

Source§

type NonZeroInner = NonZeroIsizeInner

Source§

impl ZeroablePrimitive for u8

Source§

type NonZeroInner = NonZeroU8Inner

Source§

impl ZeroablePrimitive for u16

Source§

type NonZeroInner = NonZeroU16Inner

Source§

impl ZeroablePrimitive for u32

Source§

type NonZeroInner = NonZeroU32Inner

Source§

impl ZeroablePrimitive for u64

Source§

type NonZeroInner = NonZeroU64Inner

Source§

impl ZeroablePrimitive for u128

Source§

type NonZeroInner = NonZeroU128Inner

Source§

impl ZeroablePrimitive for usize

Source§

type NonZeroInner = NonZeroUsizeInner