5 releases
| 0.1.4 | Jan 26, 2026 |
|---|---|
| 0.1.3 | Oct 6, 2025 |
| 0.1.2 | Aug 10, 2025 |
| 0.1.1 | Sep 16, 2024 |
| 0.1.0 | May 30, 2024 |
#259 in Memory management
16KB
177 lines
noop_allocator
This crate provides an Allocator which does nothing: NoopAllocator<'_>.
Specifically:
allocateandallocate_zeroedwill returnErrfor any non-zero-sized allocation requestsdeallocateis a no-op, and does not require thatptrbe "currently allocated", or fitlayout.shrink,grow, andgrow_zeroeddo not require thatptrbe "currently allocated", or fitold_layout, and will successfully return the original pointer unchanged (with the length of the new layout) if theptris aligned for the new layout and the new layout is smaller or the same size as the old layout.
This type is usable as an Allocator when you want to borrow an existing
memory range for use in a collection type, for example in
Box or Vec.
Safety:
Many functions in this crate assume that impl Allocator for NoopAllocator<'_> as described above is sound, but feature(allocator_api)
is unstable and the preconditions may change.