Skip to main content

Crate allocate

Crate allocate 

Source
Expand description

Allocator-aware Box, Vec, Arc, HashMap and the TalcAlloc bridge — re-exported through a single workspace façade.

§Why this crate exists

Stable Rust gives us 2-parameter Box<T> / Vec<T> / Arc<T> (defaulting to the global allocator), but the 3-parameter forms with a custom allocator are nightly-only. We want allocator-generic types so the shared talc-managed cache region can own everything (caps, refcounts, map storage) instead of half-talc-half-global.

The fix is allocator-api2 0.2 + talc 4.x + hashbrown 0.17 (with their allocator / allocator-api2 features). All three agree on a single Allocator trait — allocator_api2::alloc::Allocator — and Box / Vec / HashMap are all allocator-aware on stable. The only thing api2 doesn’t ship is an Arc, so we provide one in sync.

Downstream depends on allocate only — no api2, talc, hashbrown, or spinning_top entries in any other crate’s Cargo.toml.

§Module layout

Module paths mirror alloc:: where it makes sense:

Plus, at the crate root:

Modules§

boxed
Re-export of allocator_api2::boxed::Box.
collections
Allocator-aware collections.
sync
Arc<T, A> — atomically reference-counted handle backed by A.
talc
Talc allocator integration.
vec
Re-export of allocator_api2::vec::Vec.

Structs§

AllocError
The AllocError error indicates an allocation failure that may be due to resource exhaustion or to something wrong when combining the given input arguments with this allocator.
Global
The global memory allocator.
Layout
Layout of a block of memory.

Traits§

Allocator
An implementation of Allocator can allocate, grow, shrink, and deallocate arbitrary blocks of data described via Layout.