Skip to content

BrokenLamp/Arena-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arena-rs

Crates.io

An arena memory pool for fast Rust heap allocations and dealocations.

This allows data to be allocated instantly and destroyed in batches.

Creating an Arena

use arena_rs::Arena;

let mut arena = Arena::new(1024 /* size in bytes*/);

Allocating data

let value = arena.alloc(17)?;
assert_eq!(*value, 17);

Deallocating data

{
    let arena = Arena::new(1024);
} // <- All data in arena is deallocated here

Saftey

let arena = Arena::new(1024);
let value = arena.alloc(17)?;
move_arena(arena);
println!("{}", *value); // <- Compiler Error
// The arena was destroyed when we gave it to `move_arena`
// so we cannot use any data it gave to us

Releases

No releases published

Packages

No packages published

Languages