Layout

Struct Layout 

1.28.0 · Source
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

1.28.0 (const: 1.36.0) · Source

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) · Source

pub const fn size(&self) -> usize

The minimum size in bytes for a memory block of this layout.

1.28.0 (const: 1.50.0) · Source

pub const fn align(&self) -> usize

The minimum byte alignment for a memory block of this layout.

The returned alignment is guaranteed to be a power of two.

1.28.0 (const: 1.42.0) · Source

pub const fn new<T>() -> Self

Constructs a Layout suitable for holding a value of type T.

Auto Trait Implementations§

§

impl Freeze for Layout

§

impl Send for Layout

§

impl Sync for Layout

Blanket Implementations§

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.