with_arena

Function with_arena 

Source
pub fn with_arena<F, R>(f: F) -> R
where F: FnOnce(&Bump) -> R,
Expand description

Execute a function with access to the thread-local arena

This is used by CemString to allocate strings from the arena.

§Performance

~5ns vs ~100ns for global allocator (20x faster)

§Example

let arena_str = with_arena(|arena| arena.alloc_str("Hello"));