[−][src]Struct alloc_wg::alloc::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:
alignmust not be zero,alignmust be a power of two,sizemust not be zero,size, when rounded up to the nearest multiple ofalign, must not overflow (i.e., the rounded value must be less thanusize::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]
fn clone(&self) -> NonZeroLayout[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for NonZeroLayout[src]
impl Eq for NonZeroLayout[src]
impl PartialEq<NonZeroLayout> for NonZeroLayout[src]
fn eq(&self, other: &NonZeroLayout) -> bool[src]
fn ne(&self, other: &NonZeroLayout) -> bool[src]
impl Debug for NonZeroLayout[src]
impl TryFrom<Layout> for NonZeroLayout[src]
Auto Trait Implementations
impl Send for NonZeroLayout
impl Sync for NonZeroLayout
impl Unpin for NonZeroLayout
impl UnwindSafe for NonZeroLayout
impl RefUnwindSafe for NonZeroLayout
Blanket Implementations
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,