Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "alloc/arena"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
block |
alloc/block |
arena.dodo |
error |
alloc/error |
arena.dodo |
layout |
alloc/layout |
arena.dodo |
ptr |
core/ptr |
arena.dodo |
Arena
Struct · Source
Caller-backed bump allocation, with no heap, OS calls, or hidden metadata. The checked slice borrow prevents moving/dropping/reusing backing storage while the Arena is live. Returned Blocks are raw: their access is unsafe.
pub struct Arena {
// Private implementation fields omitted.
}
Arena.new
Function · Source
pub fn new(backing: &mut[u8]) -> Arena from(backing)
Arena.capacity
Function · Source
pub fn capacity(&self) -> usize
Arena.used
Function · Source
pub fn used(&self) -> usize
Arena.remaining
Function · Source
pub fn remaining(&self) -> usize
Arena.allocate
Function · Source
pub fn allocate(&mut self, requested: &layout.Layout) -> block.Block!error.AllocError
Arena.allocate_zeroed
Function · Source
pub fn allocate_zeroed(&mut self, requested: &layout.Layout) -> block.Block!error.AllocError
Arena.deallocate
Function · Source
SAFETY: allocated is a live allocation from this arena, not previously deallocated or invalidated by reset. Destroy stored values first and stop using every pointer into the block. Individual frees reclaim no space.
pub unsafe fn deallocate(&mut self, allocated: block.Block)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
Arena.reset
Function · Source
SAFETY: destroy all stored values first. Every outstanding allocation is invalidated; its pointers and descriptors must not be used again.
pub unsafe fn reset(&mut self)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.