#[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§
Auto Trait 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> UnwindSafe for AlignAs<B, T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more