Struct allocators::scoped::Scoped [] [src]

pub struct Scoped<'parent, A: 'parent + Allocator> {
    // some fields omitted
}

A scoped linear allocator.

Methods

impl Scoped<'static, HeapAllocator>
[src]

fn new(size: usize) -> Result<Self, AllocatorError>

Creates a new Scoped backed by size bytes from the heap.

impl<'parent, A: Allocator> Scoped<'parent, A>
[src]

fn new_from(alloc: &'parent A, size: usize) -> Result<Self, AllocatorError>

Creates a new Scoped backed by size bytes from the allocator supplied.

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

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

Returns the result of the closure or an error if this allocator has already been scoped.

fn is_scoped(&self) -> bool

Trait Implementations

impl<'a, A: Allocator> Allocator for Scoped<'a, A>
[src]

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

Attempt to allocate a block of memory. Read more

unsafe fn deallocate_raw(&self, blk: Block)

Deallocate the memory referred to by this pointer. Read more

fn allocate<T>(&self, val: T) -> Result<Allocated<T, Self>, (AllocatorError, T)> where Self: Sized

Attempts to allocate the value supplied to it. Read more

fn make_place<T>(&self) -> Result<Place<T, Self>, AllocatorError> where Self: Sized

Attempts to create a place to allocate into. For the general purpose, calling allocate on the allocator is enough. However, when you know the value you are allocating is too large to be constructed on the stack, you should use in-place allocation. Read more

impl<'a, A: Allocator> BlockOwner for Scoped<'a, A>
[src]

fn owns_block(&self, blk: &Block) -> bool

Whether this allocator owns the block passed to it.

fn owns<'a, T, A: Allocator>(&self, val: &Allocated<'a, T, A>) -> bool

Whether this allocator owns this allocated value.

fn with_fallback<O: BlockOwner>(self, other: O) -> Fallback<Self, O> where Self: Sized

Joins this allocator with a fallback allocator.

impl<'a, A: Allocator> Drop for Scoped<'a, A>
[src]

fn drop(&mut self)

Drops the Scoped