aboutsummaryrefslogtreecommitdiff
path: root/crates/slotmap-careful/src/key_data.rs
Commit message (Collapse)AuthorAgeFilesLines
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+1
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* New `slotmap-careful` crate to use when we mustn't re-use keys.Nick Mathewson2024-08-081-0/+281
This crate works as a drop-in replacement for the generational arena types `slotmap::{SlotMap, DenseSlotMap, HopSlotMap}`, and is implemented a set of wrappers around those types. The wrappers guarantee that slot versions numbers can never wrap around by marking as unusable any slot whose version number would otherwise get too high. (We add some leeway between our max allowed version number and the largest possible version number, so that we can detect bugs.) The code relies on the serde encoding of slotmap key versions. For notes on stability and (surprisingly good) performance, see the comments. Test coverage is around 98% for the lib.rs file; it's lower in key_data.rs, since the error cases are unreachable given slotmap's current behavior. Open questions: * What further testing is a good idea? * Will slotmap ever upstream something like this? See "# Limitations" comment for the parts of slotmap that are not implemented; I hope that we don't need them.