hashbrown icon indicating copy to clipboard operation
hashbrown copied to clipboard

Map item stability and aliasing guarantees

Open eggyal opened this issue 2 years ago • 0 comments

Am I correct in understanding that:

  • HashMap items remain stable in memory unless/until the map needs to reallocate for change of capacity; and

  • references to contained items are created only when those references are returned by a public API?

If so, could these be documented guarantees upon which one might rely for memory safety? That would enable the construction of a (fixed-capacity/non-growable but) append-only map that is capable of issuing references to its items that have the lifetime of the map itself without preventing further insertions (exposing an API around RawTable::try_insert_no_grow would aid this use-case too).

eggyal avatar Feb 02 '22 10:02 eggyal