-use std::hash::BuildHasher;\r
-use std::hash::Hash;\r
-\r
-use super::{Equivalent, IndexMap};\r
-\r
-pub struct PrivateMarker {}\r
-\r
-/// Opt-in mutable access to keys.\r
-///\r
-/// These methods expose `&mut K`, mutable references to the key as it is stored\r
-/// in the map.\r
-/// You are allowed to modify the keys in the hashmap **if the modifcation\r
-/// does not change the key’s hash and equality**.\r
-///\r
-/// If keys are modified erronously, you can no longer look them up.\r
-/// This is sound (memory safe) but a logical error hazard (just like\r
-/// implementing PartialEq, Eq, or Hash incorrectly would be).\r
-///\r
-/// `use` this trait to enable its methods for `IndexMap`.\r
-pub trait MutableKeys {\r
- type Key;\r
- type Value;\r
-\r
- /// Return item index, mutable reference to key and value\r
- fn get_full_mut2<Q: ?Sized>(\r
- &mut self,\r
- key: &Q,\r
- ) -> Option<(usize, &mut Self::Key, &mut Self::Value)>\r
- where\r
- Q: Hash + Equivalent<Self::Key>;\r
-\r
- /// Scan through each key-value pair in the map and keep those where the\r
- /// closure `keep` returns `true`.\r
- ///\r
- /// The elements are visited in order, and remaining elements keep their\r
- /// order.\r
- ///\r
- /// Computes in **O(n)** time (average).\r
- fn retain2<F>(&mut self, keep: F)\r
- where\r
- F: FnMut(&mut Self::Key, &mut Self::Value) -> bool;\r
-\r
- /// This method is not useful in itself – it is there to “seal” the trait\r
- /// for external implementation, so that we can add methods without\r
- /// causing breaking changes.\r
- fn __private_marker(&self) -> PrivateMarker;\r
-}\r
-\r
-/// Opt-in mutable access to keys.\r
-///\r
-/// See [`MutableKeys`](trait.MutableKeys.html) for more information.\r
-impl<K, V, S> MutableKeys for IndexMap<K, V, S>\r
-where\r
- K: Eq + Hash,\r
- S: BuildHasher,\r
-{\r
- type Key = K;\r
- type Value = V;\r
- fn get_full_mut2<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, &mut K, &mut V)>\r
- where\r
- Q: Hash + Equivalent<K>,\r
- {\r
- self.get_full_mut2_impl(key)\r
- }\r
-\r
- fn retain2<F>(&mut self, keep: F)\r
- where\r
- F: FnMut(&mut K, &mut V) -> bool,\r
- {\r
- self.retain_mut(keep)\r
- }\r
-\r
- fn __private_marker(&self) -> PrivateMarker {\r
- PrivateMarker {}\r
- }\r
-}\r
+use core::hash::{BuildHasher, Hash};
+
+use super::{Equivalent, IndexMap};
+
+pub struct PrivateMarker {}
+
+/// Opt-in mutable access to 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 hashmap **if the modifcation
+/// does not change the key’s hash and equality**.
+///
+/// If keys are modified erronously, 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`.
+pub trait MutableKeys {
+ type Key;
+ type Value;
+
+ /// Return item index, mutable reference to key and value
+ fn get_full_mut2<Q: ?Sized>(
+ &mut self,
+ key: &Q,
+ ) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
+ where
+ Q: Hash + Equivalent<Self::Key>;
+
+ /// 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>(&mut self, keep: F)
+ where
+ F: FnMut(&mut Self::Key, &mut Self::Value) -> bool;
+
+ /// This method is not useful in itself – it is there to “seal” the trait
+ /// for external implementation, so that we can add methods without
+ /// causing breaking changes.
+ fn __private_marker(&self) -> PrivateMarker;
+}
+
+/// Opt-in mutable access to keys.
+///
+/// See [`MutableKeys`](trait.MutableKeys.html) for more information.
+impl<K, V, S> MutableKeys for IndexMap<K, V, S>
+where
+ K: Eq + Hash,
+ S: BuildHasher,
+{
+ type Key = K;
+ type Value = V;
+ fn get_full_mut2<Q: ?Sized>(&mut self, key: &Q) -> Option<(usize, &mut K, &mut V)>
+ where
+ Q: Hash + Equivalent<K>,
+ {
+ self.get_full_mut2_impl(key)
+ }
+
+ fn retain2<F>(&mut self, keep: F)
+ where
+ F: FnMut(&mut K, &mut V) -> bool,
+ {
+ self.retain_mut(keep)
+ }
+
+ fn __private_marker(&self) -> PrivateMarker {
+ PrivateMarker {}
+ }
+}