Skip to content

Commit

Permalink
Merge pull request rust-lang#120 from bluss/get-index-of
Browse files Browse the repository at this point in the history
Rename entry_index to get_index_of
  • Loading branch information
cuviper authored Apr 14, 2020
2 parents f2142d9 + 1b54c5e commit e603553
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,16 +1023,16 @@ where
where
Q: Hash + Equivalent<K>,
{
if let Some((_, found)) = self.find(key) {
if let Some(found) = self.get_index_of(key) {
let entry = &self.core.entries[found];
Some((found, &entry.key, &entry.value))
} else {
None
}
}

/// Return item index
pub fn entry_index<Q: ?Sized>(&self, key: &Q) -> Option<usize>
/// Return item index, if it exists in the map
pub fn get_index_of<Q: ?Sized>(&self, key: &Q) -> Option<usize>
where
Q: Hash + Equivalent<K>,
{
Expand Down
6 changes: 3 additions & 3 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ where
self.map.get_full(value).map(|(i, x, &())| (i, x))
}

/// Return item index
pub fn entry_index<Q: ?Sized>(&self, value: &Q) -> Option<usize>
/// Return item index, if it exists in the set
pub fn get_index_of<Q: ?Sized>(&self, value: &Q) -> Option<usize>
where
Q: Hash + Equivalent<T>,
{
self.map.entry_index(value)
self.map.get_index_of(value)
}

/// Adds a value to the set, replacing the existing value, if any, that is
Expand Down

0 comments on commit e603553

Please sign in to comment.