Skip to content

Commit

Permalink
Adds get_index to map.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Thermatix committed Jan 31, 2020
1 parent d3eb7cd commit 008828f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,19 @@ where
}
}

/// Return item index
pub fn get_index<Q: ?Sized>(&self, key: &Q) -> Option<usize>
where
Q: Hash + Equivalent<K>,
{
if let Some((_, found)) = self.find(key) {
let entry = &self.core.entries[found];
Some(found)
} else {
None
}
}

pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V>
where
Q: Hash + Equivalent<K>,
Expand Down

0 comments on commit 008828f

Please sign in to comment.