-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more Vec/slice-like methods to maps and sets
```rust impl<K, V, S> IndexMap<K, V, S> { pub fn truncate(&mut self, len: usize); pub fn split_off(&mut self, at: usize) -> Self where S: Clone; pub fn first(&self) -> Option<(&K, &V)>; pub fn first_mut(&mut self) -> Option<(&mut K, &mut V)>; pub fn last(&self) -> Option<(&K, &V)>; pub fn last_mut(&mut self) -> Option<(&mut K, &mut V)>; pub fn swap_indices(&mut self, a: usize, b: usize); } impl<T, S> IndexSet<T, S> { pub fn truncate(&mut self, len: usize); pub fn split_off(&mut self, at: usize) -> Self where S: Clone; pub fn first(&self) -> Option<&T>; pub fn last(&self) -> Option<&T>; pub fn swap_indices(&mut self, a: usize, b: usize); } ``` I would prefer `&K` instead of `&mut K` in `IndexMap::first_mut` and `last_mut`, but this is consistent with the existing `get_index_mut`.
- Loading branch information
Showing
4 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters