allocator-suite 0.1.4

Allocator Suite for various allocation types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::alloc::Layout;
use std::intrinsics::transmute;
use std::num::NonZeroUsize;

/// Deliberately structured like Layout to provide access to fields.
pub(crate) struct LayoutHack {
    pub(crate) size_: usize,
    pub(crate) align_: NonZeroUsize,
}

impl LayoutHack {
    #[inline(always)]
    pub(crate) fn access_private_fields(layout: Layout) -> Self {
        unsafe { transmute(layout) }
    }
}