Struct toolshed::Arena [] [src]

pub struct Arena { /* fields omitted */ }

An arena implementation that uses preallocated 64KiB pages for all allocations. If a new allocation were to be pushed over the the boundaries of the page, a new page is internally allocated first, thus this version of the arena can never run out of memory unless the process runs out of heap altogether.

Allocating a type larger than the page size will result in a new heap allocation just for that type separate from the page mechanism.

Methods

impl Arena
[src]

[src]

Create a new arena with a single preallocated 64KiB page

[src]

Put the value onto the page of the arena and return a reference to it.

[src]

Allocate enough bytes for the type T, then return a pointer to the memory. Memory behind the pointer is uninitialized, can contain garbage and reading from it is undefined behavior.

[src]

Allocate an &str slice onto the arena and return a reference to it. This is useful when the original slice has an undefined lifetime.

Note: static slices (&'static str) can be safely used in place of arena-bound slices without having to go through this method.

[src]

Allocate an &str slice onto the arena as null terminated C-style string. No checks are performed on the source and whether or not it already contains any nul bytes. While this does not create any memory issues, it assumes that the reader of the source can deal with malformed source.

[src]

Pushes the String as it's own page onto the arena and returns a reference to it. This does not copy or reallocate the original String.

Trait Implementations

impl Send for Arena
[src]

Akin to CopyCell: Sync is unsafe but Send is totally fine!