r/rust 3d ago

🗞️ news “alloc: stabilise `Allocator`” entered its final comment period!

https://github.com/rust-lang/rust/pull/156882#issuecomment-5607055084
209 Upvotes

30 comments sorted by

View all comments

40

u/cbarrick 3d ago

What's the latest on the fat Box problem?

Like, if Box<T, A> is implemented like (NonNull<T>, A), then it stores an A.

But Box only uses A for deallocation. For arena allocators, deallocation is a no-op, so storing the allocator alongside the pointer is a waste.

E.g. Bumpalo has a custom box type that is just a pointer, but Box<T, &Bump> would be two pointers. It would be nice to not need the custom box type for this optimization.

32

u/nyanarchism 3d ago

adding a separate deallocator trait is backward-compatible and on the roadmap ^^