Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix possible invariant breakage in iter_mut #10

Open
mersinvald opened this issue May 10, 2018 · 2 comments
Open

Fix possible invariant breakage in iter_mut #10

mersinvald opened this issue May 10, 2018 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@mersinvald
Copy link
Owner

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.

@mersinvald
Copy link
Owner Author

Additionally, the current implementation does not support iterators over BTreeMap bucket, as it is not support invariant leakage :)

@mersinvald
Copy link
Owner Author

Probably, this should be postponed until the transition to BST-based Vec bucket implementation #11

@mersinvald mersinvald added this to the Version 0.2.0 milestone May 10, 2018
@mersinvald mersinvald added the bug Something isn't working label May 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant