[][src]Struct alloc_compose::NullAlloc

pub struct 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]

🔬 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]

🔬 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]

🔬 This is a nightly-only experimental API. (allocator_api)

Must not be called, as alloc always fails.

impl Clone for NullAlloc[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

impl Send for NullAlloc

impl Sync for NullAlloc

impl Unpin for NullAlloc

Blanket Implementations

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

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

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

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.