Struct scoped_allocator::ScopedAllocator [] [src]

pub struct ScopedAllocator {
    // some fields omitted
}

A scoped linear allocator

Methods

impl ScopedAllocator
[src]

fn new(size: usize) -> ScopedAllocator

Creates a new ScopedAllocator backed by a memory buffer of given size.

fn allocate<'a, T>(&'a self, val: T) -> Result<Allocated<'a, T>, T>

Attempts to allocate space for the T supplied to it.

This function is most definitely not thread-safe. This either returns the allocated object, or returns val back on failure.

unsafe fn allocate_raw(&self, size: usize, align: usize) -> Result<*mut u8()>

Attempts to allocate some bytes directly. Returns either a pointer to the start of the block or nothing.

fn scope<F, U>(&self, f: F) -> U where F: FnMut() -> U

Calls the supplied function with a new scope of the allocator.

Values allocated in the scope cannot be moved outside.

Trait Implementations

impl Drop for ScopedAllocator
[src]

fn drop(&mut self)

Drops the ScopedAllocator