Closed cuviper closed 7 months ago
The std-matching methods of RawEntryBuilder only return (&K, &V), but the index is also useful when working with IndexMap.
std
RawEntryBuilder
(&K, &V)
IndexMap
impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> { /// Access an entry by hash, including its index. pub fn from_hash_full<F>(self, hash: u64, is_match: F) -> Option<(usize, &'a K, &'a V)> where F: FnMut(&K) -> bool, /// Access the index of an entry by hash. pub fn index_from_hash<F>(self, hash: u64, is_match: F) -> Option<usize> where F: FnMut(&K) -> bool, }
In addition, the RawEntryMut enum can report its index by forwarding to the existing methods on its variants.
RawEntryMut
impl<'a, K, V, S> RawEntryMut<'a, K, V, S> { /// Return the index where the key-value pair exists or may be inserted. pub fn index(&self) -> usize }
The
std
-matching methods ofRawEntryBuilder
only return(&K, &V)
, but the index is also useful when working withIndexMap
.In addition, the
RawEntryMut
enum can report its index by forwarding to the existing methods on its variants.