zerocopy

Trait Unaligned

source
pub unsafe trait Unaligned { }
Expand description

Types with no alignment requirement.

WARNING: Do not implement this trait yourself! Instead, use #[derive(Unaligned)] (requires the derive Cargo feature).

If T: Unaligned, then align_of::<T>() == 1.

§Safety

This section describes what is required in order for T: Unaligned, and what unsafe code may assume of such types. #[derive(Unaligned)] only permits types which satisfy these requirements. If you don’t plan on implementing Unaligned manually, and you don’t plan on writing unsafe code that operates on Unaligned types, then you don’t need to read this section.

If T: Unaligned, then unsafe code may assume that it is sound to produce a reference to T at any memory location regardless of alignment. If a type is marked as Unaligned which violates this contract, it may cause undefined behavior.

Implementations on Foreign Types§

source§

impl Unaligned for Option<NonZeroI8>

source§

impl Unaligned for Option<NonZeroU8>

source§

impl Unaligned for bool

source§

impl Unaligned for i8

source§

impl Unaligned for str

source§

impl Unaligned for u8

source§

impl Unaligned for ()

source§

impl Unaligned for NonZeroI8

source§

impl Unaligned for NonZeroU8

source§

impl<T: Unaligned> Unaligned for [T]

source§

impl<T: Unaligned> Unaligned for Wrapping<T>

source§

impl<T: Unaligned> Unaligned for MaybeUninit<T>

source§

impl<T: ?Sized + Unaligned> Unaligned for ManuallyDrop<T>

source§

impl<T: ?Sized> Unaligned for PhantomData<T>

source§

impl<const N: usize, T: Unaligned> Unaligned for [T; N]

Implementors§

source§

impl<O> Unaligned for F32<O>

source§

impl<O> Unaligned for F64<O>

source§

impl<O> Unaligned for I16<O>

source§

impl<O> Unaligned for I32<O>

source§

impl<O> Unaligned for I64<O>

source§

impl<O> Unaligned for I128<O>

source§

impl<O> Unaligned for U16<O>

source§

impl<O> Unaligned for U32<O>

source§

impl<O> Unaligned for U64<O>

source§

impl<O> Unaligned for U128<O>

source§

impl<T> Unaligned for Unalign<T>