The state of Rust allocators in 2026: stabilised (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
Last time I tried, even the standard containers were giving different layouts to allocate and deallocate.
Also as a bonus, you get to put another template parameter to all of your containers!
Replies (4)
Replies (1)
Replies (2)
Replies (1)
bumpalo::collections::Vec<'bump, T> is a completely distinct type from std::vec::Vec<T>. You cannot pass an arena-allocated Vec or String to third-party libraries that expect standard library types without copying or converting them to slices first
Replies (1)
Slices are already the standard for interoperability between Rust libraries, and always have been. There may very well be libraries out there whose APIs expect you to pass Vecs into them, but that would be highly atypical.
Continue this thread (1 replies) →
Do you have some concrete examples? I couldn't reproduce this but maybe I'm looking in the wrong places.
Replies (1)
https://github.com/ozgrakkurt/s_alloc
Test were failing until adding this
https://github.com/ozgrakkurt/s_alloc/blob/42adbd31e9835cc17...
Also I remember finding that allocator trait explicitly mentions this after finding the error.
Replies (1)
Replies (1)
Vec<u8,Goose> and Vec<u8,Global> both implement AsRef<[u8]> and AsMut<[u8]> which means code which doesn't want to grow or shrink the Vec needn't care about the Goose allocator or interact with it in any way.
In C++ today you can write this way using std::span<T> from C++ 20, and enough people write C++ 20 that it probably won't cause overwhelming anger from people you've shut out, but in C++ 17 it could not be expressed at all, so that means even today some places cannot use your code.
For the benefit of the reader, this was two years ago.
The OP references updates made in Rust 1.100, released three weeks ago.
Replies (1)
Rust says allocation A will "fit" in allocation B if A's alignment is equal to B's and A's size is no larger than B's size.