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 Vec/slice-like methods to maps and sets #160

Merged
merged 3 commits into from
Dec 15, 2020

Commits on Dec 15, 2020

  1. 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`.
    cuviper committed Dec 15, 2020
    Configuration menu
    Copy the full SHA
    6378856 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eca535d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4819253 View commit details
    Browse the repository at this point in the history