4 ms·
> I would say RAII and Rust's borrow checker are still superior but it's definitely true that they don't work well with arenas. Note that this will definitely
by zozbot234 4y ago
> I would say RAII and Rust's borrow checker are still superior but it's definitely true that they don't work well with arenas.
Note that this will definitely improve in future versions of Rust. Local allocators are an unstable feature already, and can support arena allocation.
- williamcotton 4y agoAs a C programmer who uses memory arenas quite frequently can you expand on what you know about Rust’s current or future support for such a feature? I’d like to start writing new projects in Rust and I’d like to continue to use this approach to memory management!
- creata 4y agoYou can of course use arenas in Rust just like in C. I think the parent was talking about support for using arenas as the memory for stuff like built-in containers (dynamic arrays, hash maps, etc.): https://github.com/rust-lang/wg-allocators https://github.com/rust-lang/wg-allocators
- williamcotton 4y agoThank you! Yeah, something like bumpalo would work just fine right now but for the future this is a great interface: https://docs.rs/bumpalo/latest/bumpalo/#nightly-rust-allocator_api-support https://docs.rs/bumpalo/latest/bumpalo/#nightly-rust-allocat... use bumpalo::Bump; let bump = Bump::new(); let mut v = Vec::new_in(&bump); v.push(0); v.push(1); v.push(2);