Struct AlignAs

struct AlignAs<B: ?Sized, T> { ... }

A hack to align a smaller type B with a bigger type T.

The usual use of this is with B = [u8] and T = u32. That is, it permits aligning a sequence of bytes on a 4-byte boundary. This is useful in contexts where one wants to embed a serialized dense DFA into a Rust a program while guaranteeing the alignment required for the DFA.

See dense::DFA::from_bytes for an example of how to use this type.

Fields

_align: [T; 0]

A zero-sized field indicating the alignment we want.

bytes: B

A possibly non-sized field containing a sequence of bytes.

Implementations

impl<B, T> Freeze for AlignAs<B, T>

impl<B, T> RefUnwindSafe for AlignAs<B, T>

impl<B, T> Send for AlignAs<B, T>

impl<B, T> Sync for AlignAs<B, T>

impl<B, T> Unpin for AlignAs<B, T>

impl<B, T> UnsafeUnpin for AlignAs<B, T>

impl<B, T> UnwindSafe for AlignAs<B, T>

impl<B: $crate::fmt::Debug + ?Sized, T: $crate::fmt::Debug> Debug for AlignAs<B, T>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T> Any for AlignAs<B, T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for AlignAs<B, T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for AlignAs<B, T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for AlignAs<B, T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for AlignAs<B, T>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for AlignAs<B, T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for AlignAs<B, T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>