[−][src]Struct alloc_compose::NullAlloc
An emphatically empty implementation of AllocRef
.
Although it has no direct use, it is useful as a "terminator" in composite allocators.
Examples
The NullAlloc
will always return Err
:
#![feature(allocator_api)] use alloc_compose::NullAlloc; use std::alloc::{AllocInit, AllocRef, Global, Layout}; let memory = NullAlloc.alloc(Layout::new::<u32>(), AllocInit::Uninitialized); assert!(memory.is_err())
Even if a zero-sized allocation is requested:
#![feature(allocator_api)] use alloc_compose::NullAlloc; use std::alloc::{AllocInit, AllocRef, Global, Layout}; let memory = NullAlloc.alloc(Layout::new::<()>(), AllocInit::Uninitialized); assert!(memory.is_err())
Trait Implementations
impl AllocRef for NullAlloc
[src]
fn alloc(
&mut self,
_layout: Layout,
_init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
_layout: Layout,
_init: AllocInit
) -> Result<MemoryBlock, AllocErr>
🔬 This is a nightly-only experimental API. (
allocator_api
)Will always return Err(AllocErr)
.
unsafe fn dealloc(&mut self, _ptr: NonNull<u8>, _layout: Layout)
[src]
🔬 This is a nightly-only experimental API. (
allocator_api
)Must not be called, as alloc
always fails.
unsafe fn grow(
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement,
_init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement,
_init: AllocInit
) -> Result<MemoryBlock, AllocErr>
🔬 This is a nightly-only experimental API. (
allocator_api
)Must not be called, as alloc
always fails.
unsafe fn shrink(
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
🔬 This is a nightly-only experimental API. (
allocator_api
)Must not be called, as alloc
always fails.
fn by_ref(&mut self) -> &mut Self
[src]
impl Clone for NullAlloc
[src]
fn clone(&self) -> NullAlloc
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for NullAlloc
[src]
impl Debug for NullAlloc
[src]
impl Owns for NullAlloc
[src]
fn owns(&self, _memory: MemoryBlock) -> bool
[src]
Will always return `false.
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
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>,