Comment by kibwen
16 hours ago
Arenas in Rust work very well with lifetimes. In fact arenas benefit greatly from lifetimes, because lifetimes allow them to uphold the usual Rust safety guarantees about preventing use-after-free. For example, here's the bumpalo crate in action:
let mut arena = Bump::new(); // create arena
let foo = arena.alloc(Foo { x: 42 }); // allocate item in arena
bump.reset(); // clear arena
foo.x += 1; // compiler error preventing use-after-free
No comments yet
Contribute on Hacker News ↗