How to use std::alloc::Allocator

โš“ Rust    ๐Ÿ“… 2026-03-20    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 1      

surdeus

I 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

Read full topic

๐Ÿท๏ธ Rust_feed