Skip to main content

rkyv/util/
mod.rs

1//! Utilities for common operations.
2
3#[cfg(feature = "alloc")]
4mod alloc;
5mod inline_vec;
6mod ser_vec;
7
8use core::ops::{Deref, DerefMut};
9
10#[doc(inline)]
11#[cfg(feature = "alloc")]
12pub use self::alloc::*;
13#[doc(inline)]
14pub use self::{inline_vec::InlineVec, ser_vec::SerVec};
15
16/// A wrapper which aligns its inner value to 16 bytes.
17#[derive(Clone, Copy, Debug)]
18#[repr(C, align(16))]
19pub struct Align<T>(
20    /// The inner value.
21    pub T,
22);
23
24impl<T> Deref for Align<T> {
25    type Target = T;
26
27    fn deref(&self) -> &Self::Target {
28        &self.0
29    }
30}
31
32impl<T> DerefMut for Align<T> {
33    fn deref_mut(&mut self) -> &mut Self::Target {
34        &mut self.0
35    }
36}