#[repr(C)]
pub struct AlignAs<B: ?Sized, T> { pub _align: [T; 0], pub bytes: B, }
Expand description

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.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.