Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing and Soundness

Where unsafe Is Used

ModuleWhy
paged_dequeuninitialized slots in pages; elements are moved in and out manually
concurrentatomics publish slots and pages to other threads; guards hand out references to shared slots
Python bindingsNumPy views over container memory (guarded by export counts)

The other single-threaded containers (sparse set and map, direct map, priority queue, hive, id allocator, page directories) use no unsafe code.

Test Layers

LayerWhat it checksWhere
Unit and doctestsAPI contracts, documented examples (including the README)crates/paged-collections/src, cargo test
Model tests (proptest)random operation sequences against a standard-library oracle (Vec, VecDeque, HashMap, BTreeMap, BinaryHeap)crates/paged-collections/tests/*_model.rs
Panic safetyinvariants after panicking Drop, Ord and user closuresunit tests per container
Miriundefined behaviour in the Rust tests, including concurrent testsBefore release, outside CI
loomexhaustive interleavings (preemption bound 2) of the concurrent protocols: publication, free-stack sharding, page installation, guardssrc/concurrent/loom_*.rs
ThreadSanitizerdata races in the concurrent stress testsmanual
Compile-fail doctestslifetime invariance of every concurrent element typeconcurrent module docs
Python testsCPython protocol parity (list, deque, set, dict), batch methods, views, pickling, free threadingtests/

Running Them

cargo test --all-features
cargo +nightly miri nextest run -p paged-collections --all-features -E 'not binary(rayon)'
MIRIFLAGS="-Zmiri-tree-borrows -Zmiri-ignore-leaks" cargo +nightly miri nextest run -p paged-collections --all-features --test rayon
MIRIFLAGS="-Zmiri-tree-borrows -Zmiri-ignore-leaks" cargo +nightly miri test -p paged-collections --all-features --doc
RUSTFLAGS="--cfg loom" cargo test -p paged-collections --features concurrent --lib --release loom
cargo build -p paged-collections --no-default-features          # no_std
uv sync && uv run pytest

Miri over the full suite is slow. cargo miri nextest run runs tests in parallel. The rayon tests and doctests run under Tree Borrows because rayon’s crossbeam-epoch dependency fails the default Stacked Borrows check. The loom suite takes several minutes in release mode.