You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently PrimitiveMap::iter_mut returns Option<&mut (Key, Value)>, that makes it possible to mutate the Key and break the invariant leading to failing lookups by a new value of the Key.
Even anyone who is familiar with principals of HashMap data structure won't try to do so, it should be restricted by the API by returning Option<(Key, &mut Value)> from the iterator.
In the current iterators implementation, the native IntoIterators of used underlying data structures are used, so the solution might be in wrapping Buckets into new types and reimplementing the IntoIterator trait for them with more strict mutation constrains.
The text was updated successfully, but these errors were encountered:
Currently
PrimitiveMap::iter_mut
returnsOption<&mut (Key, Value)>
, that makes it possible tomutate
theKey
and break the invariant leading to failing lookups by a new value of theKey
.Even anyone who is familiar with principals of
HashMap
data structure won't try to do so, it should be restricted by the API by returningOption<(Key, &mut Value)>
from the iterator.In the current iterators implementation, the native
IntoIterator
s of used underlying data structures are used, so the solution might be in wrappingBucket
s into new types and reimplementing theIntoIterator
trait for them with more strict mutation constrains.The text was updated successfully, but these errors were encountered: