doc.rust-lang.org
pub mod any
Utilities for dynamic typing or type reflection.
module
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct LayoutError
The LayoutError is returned when the parameters given to Layout::from_size_align or some other Layout constructor do not satisfy its documented constraints.
struct
core
Stable since 1.50.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn size(&self) -> usize
The minimum size in bytes for a memory block of this layout.
method
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn repeat_packed(&self, n: usize) -> Result<Self, LayoutError>
Creates a layout describing the record for n instances of self, with no padding between each instance.
method
core
Stable since 1.95.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutError>
Creates a layout describing the record for n instances of self, with a suitable amount of padding between each to ensure that each instance is given its requested size and alignment. On success, returns (k, offs) where k is the layout of the array and offs is the distance between the start of each element in the array.
method
core
Stable since 1.95.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn pad_to_align(&self) -> Layout
Creates a layout by rounding the size of this layout up to a multiple of the layout's alignment.
method
core
Stable since 1.44.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new<T>() -> Self
Constructs a Layout suitable for holding a value of type T.
associated_function
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self
Creates a layout, bypassing all checks.
associated_function
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutError>
Constructs a Layout from a given size and align, or returns LayoutError if any of the following conditions are not met:
associated_function
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn for_value_raw<T>(val: *const T) -> Self
Produces layout describing a record that could be used to allocate backing structure for T (which could be a trait or other unsized type like a slice).
associated_function
core
Stable since 1.100.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn for_value<T>(t: &T) -> Self
Produces layout describing a record that could be used to allocate backing structure for T (which could be a trait or other unsized type like a slice).
associated_function
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn extend_packed(&self, next: Self) -> Result<Self, LayoutError>
Creates a layout describing the record for self followed by next with no additional padding between the two. Since no padding is inserted, the alignment of next is irrelevant, and is not incorporated at all into the resulting layout.
method
core
Stable since 1.95.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn extend(&self, next: Self) -> Result<(Self, usize), LayoutError>
Creates a layout describing the record for self followed by next, including any necessary padding to ensure that next will be properly aligned, but no trailing padding.
method
core
Stable since 1.44.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn dangling_ptr(&self) -> NonNull<u8>
Creates a NonNull that is dangling, but well-aligned for this Layout.
method
core
Stable since 1.95.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn array<T>(n: usize) -> Result<Self, LayoutError>
Creates a layout describing the record for a [T; n].
associated_function
core
Stable since 1.44.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn align_to(&self, align: usize) -> Result<Self, LayoutError>
Creates a layout describing the record that can hold a value of the same layout as self, but that also is aligned to alignment align (measured in bytes).
method
core
Stable since 1.44.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn align(&self) -> usize
The minimum byte alignment for a memory block of this layout.
method
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct Layout
Layout of a block of memory.
struct
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8
Shrinks or grows a block of memory to the given new_size in bytes. The block is described by the given ptr pointer and layout.
method
core
Stable since 1.28.0
Version 1.100.0-nightly
doc.rust-lang.org
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
Deallocates the block of memory at the given ptr pointer with the given layout.
method
core
Stable since 1.28.0
Version 1.100.0-nightly