lazy_bytes_cast

Function uninit_byte_slice_from

Source
pub const fn uninit_byte_slice_from<T>(val: &T) -> &[MaybeUninit<u8>]
Expand description

Gets uninit byte slice out of the type.

Because type of any size can be safely represented as slice of uninitialized bytes, this method is safe to use. It is up to user to interpret result correctly and safe.

§Usage

use lazy_bytes_cast::uninit_byte_slice_from;
use core::mem::MaybeUninit;

static BYTES: &[MaybeUninit<u8>] = uninit_byte_slice_from(&0u32);

§Restrictions

Compilation fails for ZST.

use lazy_bytes_cast::uninit_byte_slice_from;
use core::mem::MaybeUninit;

static BYTES: &[MaybeUninit<u8>] = uninit_byte_slice_from(&());