pub trait ComputeAllocator<F, Mem: ComputeMemory<F>> {
// Required methods
fn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>;
fn capacity(&self) -> usize;
fn subscope_allocator(&mut self) -> impl ComputeAllocator<F, Mem>;
}
Required Methods§
Sourcefn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>
fn alloc(&self, n: usize) -> Result<Mem::FSliceMut<'_>, Error>
Allocates a slice of elements.
This method operates on an immutable self reference so that multiple allocator references
can co-exist. This follows how the bumpalo
crate’s Bump
interface works. It may not be
necessary actually (since this partitions a borrowed slice, whereas Bump
owns its memory).
§Pre-conditions
n
must be a multiple ofMem::ALIGNMENT
Sourcefn subscope_allocator(&mut self) -> impl ComputeAllocator<F, Mem>
fn subscope_allocator(&mut self) -> impl ComputeAllocator<F, Mem>
Returns the remaining unallocated capacity as a new allocator with a limited scope.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.