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

Add more methods matching the standard HashMap #136

Merged
merged 1 commit into from
Jul 16, 2020

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jul 8, 2020

  • pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)>

    • Stabilized in Rust 1.40.
    • This is a middle-ground between get and our own get_full that
      includes the index. It's easy enough to add for compatibility.
  • pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>

    • Stabilized in Rust 1.27.
    • For IndexMap, this also adds swap_/shift_remove_entry choices.
    • These are also a middle-ground between (swap_/shift_)remove and
      our own swap/shift_remove_full that include the index. We don't
      have a plain remove_full though.

- `pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)>`
  - Stabilized in Rust 1.40.
  - This is a middle-ground between `get` and our own `get_full` that
    includes the index. It's easy enough to add for compatibility.

- `pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>`
  - Stabilized in Rust 1.27.
  - For `IndexMap`, this also adds `swap_`/`shift_remove_entry` choices.
  - These are also a middle-ground between (`swap_`/`shift_`)`remove` and
    our own `swap`/`shift_remove_full` that include the index. We don't
    have a plain `remove_full` though.
@cuviper
Copy link
Member Author

cuviper commented Jul 16, 2020

I'm going ahead with the merge, because there's no real API design here. This is just matching std methods, plus swap/shift semantics, and the implementations are trivial.

@cuviper cuviper merged commit 8973b0f into indexmap-rs:master Jul 16, 2020
@cuviper cuviper deleted the std-parity branch July 23, 2020 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant