Trait Uninit

Source
pub unsafe trait Uninit: Copy {
    // Provided method
    fn alloc() -> Box<Self> { ... }
}
Available on crate feature bucket-array only.
Expand description

Marker trait for types that are normally assumed uninitialized

§Safety

By implementing this trait, it’s a guarantee that uninitialized memory may be transmuted into this type safely. It implies that the type is Copy. It should contain no bits except for MaybeUninit fields. Structs and arrays made entirely of MaybeUninit are fine.

This memory is always assumed to be uninitialized unless we hold a mutable reference that’s associated with information about specific fields that were initialized during the reference’s lifetime.

Provided Methods§

Source

fn alloc() -> Box<Self>

Allocate new uninitialized memory, returning a new Box.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<const N: usize, const M: usize, T: Copy> Uninit for BucketArrayMemory<N, M, T>

Implements the Uninit trait. This memory is always assumed to be uninitialized unless we hold a mutable reference paired with bucket usage information.

SAFETY: We can implement Uninit for BucketArrayMemory because it’s Copy and it contains only MaybeUninit bits.