pub struct Layout { /* private fields */ }
Expand description
Layout of a block of memory.
An instance of Layout
describes a particular layout of memory.
You build a Layout
up as an input to give to an allocator.
All layouts have an associated size and a power-of-two alignment. The size, when rounded up to
the nearest multiple of align
, does not overflow isize
(i.e., the rounded value will always be
less than or equal to isize::MAX
).
(Note that layouts are not required to have non-zero size,
even though GlobalAlloc
requires that all memory requests
be non-zero in size. A caller must either ensure that conditions
like this are met, use specific allocators with looser
requirements, or use the more lenient Allocator
interface.)
Implementations§
Source§impl Layout
impl Layout
1.28.0 (const: 1.36.0) · Sourcepub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self
Creates a layout, bypassing all checks.
§Safety
This function is unsafe as it does not verify the preconditions from
[Layout::from_size_align
].
1.28.0 (const: 1.50.0) · Sourcepub const fn size(&self) -> usize
pub const fn size(&self) -> usize
The minimum size in bytes for a memory block of this layout.