Struct scoped_allocator::ScopedAllocator
[−]
[src]
pub struct ScopedAllocator<'parent, A: 'parent + Allocator> { /* fields omitted */ }
A scoped linear allocator
Methods
impl ScopedAllocator<'static, HeapAllocator>
[src]
fn new(size: usize) -> Result<Self, AllocatorError>
Creates a new ScopedAllocator
backed by size
bytes from the heap.
impl<'parent, A: Allocator> ScopedAllocator<'parent, A>
[src]
fn new_from(alloc: &'parent A, size: usize) -> Result<Self, AllocatorError>
Creates a new ScopedAllocator
backed by size
bytes from the allocator supplied.
fn scope<F, U>(&self, f: F) -> Result<U, ()> where
F: FnMut(&Self) -> U,
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 ScopedAllocator<'a, A>
[src]
unsafe fn allocate_raw(
&self,
size: usize,
align: usize
) -> Result<*mut u8, AllocatorError>
&self,
size: usize,
align: usize
) -> Result<*mut u8, AllocatorError>
Attempt to allocate a block of memory. Read more
unsafe fn deallocate_raw(&self, ptr: *mut u8, size: usize, align: usize)
Deallocate the memory referred to by this pointer. Read more
fn allocate_val<'a, T>(
&'a self,
val: T
) -> Result<Allocated<'a, T, Self>, (AllocatorError, T)> where
Self: Sized,
&'a self,
val: T
) -> Result<Allocated<'a, T, Self>, (AllocatorError, T)> where
Self: Sized,
Attempts to allocate space for the value supplied to it. This incurs an expensive memcpy. If the performance of this allocation is important to you, it is recommended to use the in-place syntax with the allocate
function. Read more
fn allocate<'a, T>(&'a self) -> Result<Place<'a, T, Self>, AllocatorError> where
Self: Sized,
Self: Sized,
Attempts to create a place to allocate into.
impl<'a, A: Allocator> Drop for ScopedAllocator<'a, A>
[src]
fn drop(&mut self)
Drops the ScopedAllocator