3 ms·
A lot of concepts don’t directly mean you have to write bad code but they push you in that direction. Fact is, arena allocation or any other kind of custom allo
by ozgrakkurt 2y ago
A lot of concepts don’t directly mean you have to write bad code but they push you in that direction. Fact is, arena allocation or any other kind of custom allocation is pretty much non-existent in rust.
Hopefully it will be implemented soon but I’m not sure if it is feasible because of lifetimes
- whytevuhuni 2y agoHow so? I've been using arena allocation with the bumpalo crate [1] with great success. I also wrote my own arena allocator for a WASM project, and also wrapped Nginx's memory pool via safe APIs. I'm not going to claim that writing one correctly is easy... much like writing any low-level allocators, you have to deal with layout, drop order, unsafe cells, etc. But using them? The lifetimes work great with them. And the allocator trait [2], once released, will make it so std collection types can be used as well. [1] https://docs.rs/bumpalo https://docs.rs/bumpalo [2] https://doc.rust-lang.org/std/alloc/trait.Allocator.html https://doc.rust-lang.org/std/alloc/trait.Allocator.html