Rust 1.100 (2026-11-12) finally stabilized the core of
allocator_api. After roughly ten years in limbo, what landed is not the whole feature. It is a deliberate MVP: theAllocatortrait, plus support inVecandBox. Using the stabilization report and real examples, this article covers what you can use now, what you still can't, and why it ended up this shape.
allocator_api, enabling library authors to define custom allocators that can be used together with certain standard library types – currently Vec and Box." It calls this the foundation of the Allocators 1.0 project goal. The tracking issue is #32838, the design goes back to RFC 1398, and the feature had been nightly-only since 2016.Vec::new_in, which "is now available in stable Rust." On 11-24, cetra3's post "The State of Allocators in 2026 - Finally Stabilised!" went up on Lobsters with code for four use cases: arenas, memory accounting, stack-first allocation, and block-aligned buffers.Until now, stable Rust really had one way to change allocators: #[global_allocator] with GlobalAlloc, which swaps the allocator for the whole process (jemalloc, mimalloc, and so on). But what you usually want is a different strategy for just one part of the program:
Drop cost node by node on a deep tree.O_DIRECT.Until now, the answer was a dedicated collection type for each need: bumpalo's own collections, smallvec, aligned-vec, the allocator-api2 polyfill. The result was fragmentation. Something that is "just a Vec" got a different type and API purely because it allocates differently. cetra3 puts the question this way: if you want both block-aligned vecs and stack-allocated vecs, do you really pull in smallvec and aligned-vec? The goal of stabilization is to swap the allocation strategy through a type parameter while keeping the std collections.
pub unsafe trait Allocator {
// required
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout);
// provided
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
unsafe fn grow(&self, ptr: NonNull<u8>, old: Layout, new: Layout) -> Result<NonNull<[u8]>, AllocError>;
unsafe fn grow_zeroed(&self, ptr: NonNull<u8>, old: Layout, new: Layout) -> Result<NonNull<[u8]>, AllocError>;
unsafe fn shrink(&self, ptr: NonNull<u8>, old: Layout, new: Layout) -> Result<NonNull<[u8]>, AllocError>;
}
The design decisions worth knowing:
&self. Mutable state, like a bump pointer or a counter, lives behind Cell or atomics. std ships blanket impls for &A, &mut A, Box<A>, Rc<A>, and Arc<A>. The docs say Allocator "is mostly designed to be implemented on ZSTs, references, or smart pointers," and that a type like MyAlloc([u8; N]), which owns the memory itself, "cannot be soundly created without being pinned or otherwise immovable." That is why every one of cetra3's examples is written as impl Allocator for &Bump.NonNull<[u8]>. An allocator may hand back more than was requested, and callers can use the excess as capacity. A plain NonNull<u8> return was rejected on the grounds that the wide pointer costs nothing under common calling conventions.GlobalAlloc. Taking a NonZeroLayout, or making allocate unsafe, were both rejected for usability reasons. The report also records libs members' view that GlobalAlloc's design "was not desirable in hindsight."AllocError. An associated error type was rejected because of the added complexity and because it would break dyn compatibility.