[][src]Struct alloc_compose::Null

pub struct Null;

An emphatically empty implementation of AllocRef.

Although it has no direct use, it is useful as a "terminator" in composite allocators or for disabling the global allocator.

Examples

The Null will always return Err:

#![feature(allocator_api)]

use alloc_compose::Null;
use std::alloc::{AllocRef, Global, Layout};

let memory = Null.alloc(Layout::new::<u32>());
assert!(memory.is_err())

Even if a zero-sized allocation is requested:

let memory = Null.alloc(Layout::new::<()>());
assert!(memory.is_err())

Disabling the global allocator

use alloc_compose::Null;

#[global_allocator]
static A: Null = Null;

Trait Implementations

impl AllocRef for Null[src]

pub fn alloc(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>[src]

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

Will always return Err(AllocErr).

pub fn alloc_zeroed(&self, _layout: Layout) -> Result<NonNull<[u8]>, AllocError>[src]

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

Will always return Err(AllocErr).

pub unsafe fn dealloc(&self, _ptr: NonNull<u8>, _layout: Layout)[src]

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

Must not be called, as allocation always fails.

pub unsafe fn grow(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
[src]

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

Must not be called, as allocation always fails.

pub unsafe fn grow_zeroed(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
[src]

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

Must not be called, as allocation always fails.

pub unsafe fn shrink(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<NonNull<[u8]>, AllocError>
[src]

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

Must not be called, as allocation always fails.

impl AllocateAll for Null[src]

impl Clone for Null[src]

impl Copy for Null[src]

impl Debug for Null[src]

impl GlobalAlloc for Null[src]

impl Owns for Null[src]

pub fn owns(&self, _memory: NonNull<[u8]>) -> bool[src]

Will always return `false.

impl ReallocateInPlace for Null[src]

pub unsafe fn grow_in_place(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<usize, AllocError>
[src]

Must not be called, as allocation always fails.

pub unsafe fn grow_in_place_zeroed(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<usize, AllocError>
[src]

Must not be called, as allocation always fails.

pub unsafe fn shrink_in_place(
    &self,
    _ptr: NonNull<u8>,
    _old_layout: Layout,
    _new_layout: Layout
) -> Result<usize, AllocError>
[src]

Must not be called, as allocation always fails.

Auto Trait Implementations

impl Send for Null

impl Sync for Null

impl Unpin for Null

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.