alloc: stabilise `Allocator`
The Issue & Context
The Allocator trait, part of the allocator_api feature, has been under development to provide a safe and flexible interface for custom memory allocation strategies in Rust. This effort aligns with RFC #1398 and addresses long-standing requests tracked by issue #32838, involving multiple working groups and ecosystem contributors.
Root Cause Analysis
Previously, the Allocator trait and its API were unstable and fragmented, limiting the ability to use custom allocators safely and ergonomically across the standard library and user code. The lack of a minimal, stable interface prevented wider adoption and integration with types like Box.
Solution Strategy & Architectural Pattern
This PR stabilizes a minimal viable Allocator trait API, including essential methods like allocate and deallocate, plus default implementations for zeroed allocation, growth, and shrinking. It also integrates the Allocator trait with core types such as Box, enabling generic allocation strategies while ensuring safety and backward compatibility.
Key Takeaway for Contributors
Stabilizing the Allocator trait unlocks customizable memory management in Rust's standard library, paving the way for more efficient and flexible allocation patterns in safe Rust code and ecosystem crates.