Skip to content

Commit

Permalink
Return &K in first_mut/last_mut
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Dec 15, 2020
1 parent 6378856 commit eca535d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,16 +721,16 @@ impl<K, V, S> IndexMap<K, V, S> {
self.as_entries().first().map(Bucket::refs)
}

pub fn first_mut(&mut self) -> Option<(&mut K, &mut V)> {
self.as_entries_mut().first_mut().map(Bucket::muts)
pub fn first_mut(&mut self) -> Option<(&K, &mut V)> {
self.as_entries_mut().first_mut().map(Bucket::ref_mut)
}

pub fn last(&self) -> Option<(&K, &V)> {
self.as_entries().last().map(Bucket::refs)
}

pub fn last_mut(&mut self) -> Option<(&mut K, &mut V)> {
self.as_entries_mut().last_mut().map(Bucket::muts)
pub fn last_mut(&mut self) -> Option<(&K, &mut V)> {
self.as_entries_mut().last_mut().map(Bucket::ref_mut)
}

/// Remove the key-value pair by index
Expand Down

0 comments on commit eca535d

Please sign in to comment.