How to use std::alloc::Allocator
โ Rust ๐ 2026-03-20 ๐ค surdeus ๐๏ธ 1I have just made a basic implementation of Box ( after doing BTreeMap, BTreeSet and Vec), for my pstd crate, which has parts of Rust std library ( different implementations, features not yet stabilised etc ), and I was thinking about experimenting with a non-default Allocator.
The question is โwhat to doโ? One idea is to have a special thread-local allocator for types I know will not persist beyond the lifetime of the thread, it can be a simple โbumpโ allocator which should be fast, and deallocate could just keep a running total and free everything at once. Does that make sense? I think it might work, but the details might be trickier than I am anticipating.
Has anyone experimented with std::alloc::Allocator, and if so was it beneficial?
3 posts - 2 participants
๐ท๏ธ Rust_feed