-
Notifications
You must be signed in to change notification settings - Fork 19
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
Modifying key without changing order #18
Comments
I think it would make more sense for hashbrown to have an easy way to reinsert an entry after modifying its key first before adding it here. I have created a PR on hashbrown (rust-lang/hashbrown#450) to add a |
I think I just ran into this... Ethiraric/yaml-rust2#35 Summary: I'd recommend replacing use of the entry / and_modify / or_insert_with pattern (which moves entries to the end) to the contains_key / replace / insert pattern. More info at the above link. |
After the cursor API PR #25 was merged it's possible now to insert elements into any location within the underlying doulby-linked list. I hope that helps resolving addressing issue. |
I think that
Yes, I think this PR allows doing this. To update a key you can now use Thanks for the responses! |
Hello, thank you for this very nice crate!
Is there a way to modify an entry's key without changing its position? I use this crate to implement a cache and sometimes the key associated with an object changes, so I would like to modify it without having to reinsert the entry as it would put it on the back.
In case there is no such API, would you accept a PR that adds it? If so, how do you think that API should look like?
I thought about adding a
replace_key
method onLinkedHashMap
itself, or maybe adding areinsert
method onRawOccupiedEntryMut
but the latter looks more complicated because theRawOccupiedEntryMut
does not have a reference to the hashbrownHashMap
and I think it cannot be added because the hashbrown raw entry borrows it. I don't really know how these methods should handle an entry with the new key already existing. In my case, I would like to cancel the operation.The text was updated successfully, but these errors were encountered: