Closed zesterer closed 2 years ago
Is it the case that slotmap will ensure that old index + generation pairs cannot be recreated, even when serializing and then deserializing?
Yes, the version for each slot is included in the serialization format, and can only ever be incremented*. So old keys remain invalid.
* In the current version of slotmap if a slot gets re-used 2^31 times the version field will overflow and theoretically very old keys would become temporarily valid again (only one at a time). In the future I plan to 'retire' such a slot instead, simply never re-using it again. This technically would leak memory, but only one slot for every 2^31 insertion/deletion pairs on average, so well-worth the trade-off to never ever accidentally validate old keys.
Thanks for the clarification!
Hello,
I'm using the
serde
feature to serialize both keys and aSlotMap
. When deserializing, I want to be sure that old keys (i.e: those that no longer correspond to an entry in theSlotMap
) are not able to accidentally reoccur when inserting new items. Is it the case thatslotmap
will ensure that old index + generation pairs cannot be recreated, even when serializing and then deserializing?