2 releases

0.4.3 Jul 18, 2023
0.4.2 Jul 16, 2023

#892 in Memory management

Download history 1048/week @ 2025-11-16 1097/week @ 2025-11-23 1265/week @ 2025-11-30 1186/week @ 2025-12-07 939/week @ 2025-12-14 966/week @ 2025-12-21 748/week @ 2025-12-28 730/week @ 2026-01-04 762/week @ 2026-01-11 1172/week @ 2026-01-18 1403/week @ 2026-01-25 1427/week @ 2026-02-01 1235/week @ 2026-02-08 1481/week @ 2026-02-15 1246/week @ 2026-02-22 1020/week @ 2026-03-01

5,103 downloads per month
Used in 13 crates (via retour)

MIT license

18KB
387 lines

This crate provides functionality for using a sliceable type as the underlying memory for a pool.

The allocated memory can be a mutable slice of any type.

use slice_pool::sync::SlicePool;

let values = vec![10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
let mut memory = SlicePool::new(values);
assert_eq!(memory.len(), 10);

// Not enough memory available (only 10 elements)
assert!(memory.alloc(11).is_none());

let mut first = memory.alloc(2).unwrap();
assert_eq!(*first, [10, 20]);
first[1] = 15;
assert_eq!(*first, [10, 15]);

let mem2 = memory.alloc(5).unwrap();
assert_eq!(*mem2, [30, 40, 50, 60, 70]);

slice-pool

A Rust library for using a slice as a memory pool.

Documentation

https://docs.rs/slice-pool2

Installation

Add this to your Cargo.toml:

[dependencies]
slice-pool2 = "0.4.2"

No runtime deps