/// Opt-in mutable access to [`IndexMap`] keys. /// /// These methods expose `&mut K`, mutable references to the key as it is stored /// in the map. /// You are allowed to modify the keys in the map **if the modification /// does not change the key's hash and equality**. /// /// If keys are modified erroneously, you can no longer look them up. /// This is sound (memory safe) but a logical error hazard (just like /// implementing `PartialEq`, `Eq`, or `Hash` incorrectly would be). /// /// `use` this trait to enable its methods for `IndexMap`. /// /// This trait is sealed and cannot be implemented for types outside this crate. pubtrait MutableKeys: private::Sealed { type Key; type Value;
/// Return item index, mutable reference to key and value /// /// Computes in **O(1)** time (average). fn get_full_mut2<Q>(&mutself, key: &Q) -> Option<(usize, &e='color:red'>mutSelf::Key, &mutSelf::Value)> where
Q: ?Sized + Hash + Equivalent<Self::Key>;
/// Return mutable reference to key and value at an index. /// /// Valid indices are `0 <= index < self.len()`. /// /// Computes in **O(1)** time. fn get_index_mut2(&mutself, index: usize) -> Option<(&mutSelf::Key, &mutSelf::Value)>;
/// Return an iterator over the key-value pairs of the map, in their order fn iter_mut2(&mutself) -> IterMut2<'_, Self::Key, Self::Value>;
/// Scan through each key-value pair in the map and keep those where the /// closure `keep` returns `true`. /// /// The elements are visited in order, and remaining elements keep their /// order. /// /// Computes in **O(n)** time (average). fn retain2<F>(&mutself, keep: F) where
F: FnMut(&mutSelf::Key, &mutSelf::Value) -> bool;
}
/// Opt-in mutable access to [`IndexMap`] keys. /// /// See [`MutableKeys`] for more information. impl<K, V, S> MutableKeys for IndexMap<K, V, S> where
S: BuildHasher,
{ type Key = K; type Value = V;
/// Opt-in mutable access to [`Entry`] keys. /// /// These methods expose `&mut K`, mutable references to the key as it is stored /// in the map. /// You are allowed to modify the keys in the map **if the modification /// does not change the key's hash and equality**. /// /// If keys are modified erroneously, you can no longer look them up. /// This is sound (memory safe) but a logical error hazard (just like /// implementing `PartialEq`, `Eq`, or `Hash` incorrectly would be). /// /// `use` this trait to enable its methods for `Entry`. /// /// This trait is sealed and cannot be implemented for types outside this crate. pubtrait MutableEntryKey: private::Sealed { type Key;
/// Gets a mutable reference to the entry's key, either within the map if occupied, /// or else the new key that was used to find the entry. fn key_mut(&mutself) -> &mutSelf::Key;
}
/// Opt-in mutable access to [`Entry`] keys. /// /// See [`MutableEntryKey`] for more information. impl<K, V> MutableEntryKey for Entry<'_, K, V> { type Key = K; fn key_mut(&mutself) -> &mutSelf::Key { matchself {
Entry::Occupied(e) => e.key_mut(),
Entry::Vacant(e) => e.key_mut(),
}
}
}
/// Opt-in mutable access to [`OccupiedEntry`] keys. /// /// See [`MutableEntryKey`] for more information. impl<K, V> MutableEntryKey for OccupiedEntry<'_, K, V> { type Key = K; fn key_mut(&mutself) -> &mutSelf::Key { self.key_mut()
}
}
/// Opt-in mutable access to [`VacantEntry`] keys. /// /// See [`MutableEntryKey`] for more information. impl<K, V> MutableEntryKey for VacantEntry<'_, K, V> { type Key = K; fn key_mut(&mutself) -> &mutSelf::Key { self.key_mut()
}
}
/// Opt-in mutable access to [`IndexedEntry`] keys. /// /// See [`MutableEntryKey`] for more information. impl<K, V> MutableEntryKey for IndexedEntry<'_, K, V> { type Key = K; fn key_mut(&mutself) -> &mutSelf::Key { self.key_mut()
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.