[][src]Struct alloc_wg::alloc::NonZeroLayout

pub struct NonZeroLayout(_);

Non-zero Layout of a block of memory.

An instance of NonZeroLayout describes a particular layout of memory. You build a NonZeroLayout up as an input to give to an allocator.

All layouts have an associated non-negative size and a power-of-two alignment.

Methods

impl NonZeroLayout[src]

pub fn from_size_align(size: usize, align: usize) -> Result<Self, LayoutErr>[src]

Constructs a Layout from a given size and align, or returns LayoutErr if either of the following conditions are not met:

  • align must not be zero,
  • align must be a power of two,
  • size must not be zero,
  • size, when rounded up to the nearest multiple of align, must not overflow (i.e., the rounded value must be less than usize::MAX).

pub const unsafe fn from_size_align_unchecked(size: usize, align: usize) -> Self[src]

Creates a layout, bypassing all checks.

Safety

This function is unsafe as it does not verify the preconditions from NonZeroLayout::from_size_align.

pub fn size(&self) -> usize[src]

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

pub fn align(&self) -> usize[src]

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

pub fn new<T>() -> Result<Self, LayoutErr>[src]

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

Returns Err if T is a ZST.

pub const unsafe fn new_unchecked<T>() -> Self[src]

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

Safety

This function is unsafe as it does not verify the preconditions from NonZeroLayout::new.

pub fn for_value<T: ?Sized>(t: &T) -> Result<Self, LayoutErr>[src]

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).

Returns Err if T is a ZST.

pub unsafe fn for_value_unchecked<T: ?Sized>(t: &T) -> Self[src]

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).

Safety

This function is unsafe as it does not verify the preconditions from NonZeroLayout::for_value.

Trait Implementations

impl Into<Layout> for NonZeroLayout[src]

impl Clone for NonZeroLayout[src]

impl Copy for NonZeroLayout[src]

impl Eq for NonZeroLayout[src]

impl PartialEq<NonZeroLayout> for NonZeroLayout[src]

impl Debug for NonZeroLayout[src]

impl TryFrom<Layout> for NonZeroLayout[src]

type Error = LayoutErr

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]