Re-exported from alloc::arena::Arena!.
forall 'k.
struct Arena! { ... }
A bump allocator over a chain of heap chunks, every value in it under the one brand 'k.
root/back describe the root chunk's data buffer -- the block Arena!::new allocates, over which 'k was minted (see the module comment for why only the root). current is the head of the chunk chain, and marker is the same brand as a value, which alloc needs to brand the pointers it computes. seed is what the arena's maps hash their keys under (ArenaMap, core::hash).
Methods
method newsource
fn new(seed: Seed) -> exists '1. (Exclusive!['1], Arena!['1]) { ... }
A new arena with one 4 KiB chunk, under a fresh brand, with its capability; the maps made in it hash their keys under seed.
method markersource
fn marker(&self) -> Brand['k] { ... }
The arena's brand, for code that builds objects in its domain itself. Holding the arena is what entitles a caller to put new objects in its domain; the capability alone never does.
method seedsource
fn seed(&self) -> Seed { ... }
The seed the arena's maps hash their keys under.
method allocsource
forall T where Copy[T], Sized[T].
fn alloc(&self, &tag: Exclusive!['k], val: T) -> Ref[T, 'k] { ... }
Puts val in the arena and hands back a Ref to it.
Allocates naturally aligned room for one T, writes val into it, and hands back a Ref under the arena's own, never-changing brand -- growing into a fresh chunk first if the current one doesn't have room for both alignment padding and the value, but never rebranding either way. T is Copy: the arena frees its chunks without reading them, so a linear value stored here would never reach its consumer.
method alloc_slicesource
forall T where Copy[T], Sized[T].
fn alloc_slice(&self, &tag: Exclusive!['k], count: usize, fill: T) -> Slice[T, 'k] { ... }
Fills count new elements of the arena with fill and hands back a view of them.
Allocates room for count values of T in one naturally aligned block, writes fill into each, and hands back a view of them under the arena's brand, which, as with alloc, never changes. T is Copy because fill is written count times.
method destroysource
fn destroy(self, tag: Exclusive!['k]) -> () { ... }
Frees every chunk. See the module comment for why this cannot route every contained value through a consumer the way Vec!'s teardown does.
The caller's witness is consumed by real work: resume demands this exact Exclusive!['k] and rebuilds the root chunk's Region![u8,'k], release demands that complete region and returns the Uninit! whose base and extent Allocation!::adopt_value read off the allocator, and drop frees it. No Ref is constructed on the path. The remaining headers and non-root buffers are freed by free_chain_after_root_release.
method alloc_bytessource
unsafe fn alloc_bytes(&self, n: usize) -> *u8 { ... }
Bump-allocates n raw, uninitialized bytes and returns a bare pointer, with no brand. For a caller with a finished, exact-length run of bytes to copy in once (e.g. built in a scratch Buffer!), so the result can be read many times without linear tracking. Unlike alloc, nothing is written; the caller copies the bytes in (see copy_bytes). No alignment padding is added.
Caller: writes the n bytes before reading any of them, and uses the pointer only while the arena lives.
Instances
instance Access[Domain!['k] -> 'k, Arena!['k]]source
forall 'k.
instance Access[Domain!['k] -> 'k, Arena!['k]] { ... }
In std::arena.
A domain lends its capability, with its arena as the rest.