+3
-3
@@ -6,3 +6,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| # with all versions of Cargo and also rewrite `path` dependencies | ||
| # to registry (e.g., crates.io) dependencies | ||
| # to registry (e.g. crates.io) dependencies | ||
| # | ||
@@ -17,3 +17,3 @@ # If you believe there's an error in this file please file an | ||
| name = "im-rc" | ||
| version = "12.3.3" | ||
| version = "12.3.4" | ||
| authors = ["Bodil Stokke <bodil@bodil.org>"] | ||
@@ -49,3 +49,3 @@ build = "./build.rs" | ||
| [dependencies.sized-chunks] | ||
| version = "0.1.1" | ||
| version = "0.1.2" | ||
@@ -52,0 +52,0 @@ [dependencies.typenum] |
+14
-0
@@ -9,2 +9,16 @@ # Changelog | ||
| ## [12.3.4] - 2019-04-08 | ||
| ### Changed | ||
| - `Clone` constraints have been further relaxed on maps and sets, so that you | ||
| can now lookup and iterate over them without requiring a `Clone` constraint | ||
| (though you do still need `Clone` to actually insert data into them to lookup | ||
| or iterate over). (#81) | ||
| ### Fixed | ||
| - Enforces the latest bugfix release of sized-chunks. (#78) | ||
| - Another edge case bugfix to `Vector`'s size table handling. (#79) | ||
| ## [12.3.3] - 2019-03-11 | ||
@@ -11,0 +25,0 @@ |
+160
-162
@@ -106,4 +106,3 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| where | ||
| K: Eq + Clone, | ||
| V: Clone, | ||
| K: Eq, | ||
| { | ||
@@ -328,4 +327,3 @@ type Key = K; | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Clone, | ||
| K: Hash + Eq, | ||
| S: BuildHasher, | ||
@@ -335,2 +333,3 @@ { | ||
| where | ||
| K: Hash + Eq, | ||
| V: PartialEq, | ||
@@ -356,18 +355,2 @@ { | ||
| /// Get a mutable iterator over the values of a hash map. | ||
| /// | ||
| /// Please note that the order is consistent between maps using | ||
| /// the same hasher, but no other ordering guarantee is offered. | ||
| /// Items will not come out in insertion order or sort order. | ||
| /// They will, however, come out in the same order every time for | ||
| /// the same map. | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { | ||
| let root = Ref::make_mut(&mut self.root); | ||
| IterMut { | ||
| it: NodeIterMut::new(root, self.size), | ||
| } | ||
| } | ||
| /// Get the value for a key from a hash map. | ||
@@ -401,4 +384,3 @@ /// | ||
| /// Get a mutable reference to the value for a key from a hash | ||
| /// map. | ||
| /// Test for the presence of a key in a hash map. | ||
| /// | ||
@@ -414,10 +396,13 @@ /// Time: O(log n) | ||
| /// let map = hashmap!{123 => "lol"}; | ||
| /// assert_eq!( | ||
| /// map.get(&123), | ||
| /// Some(&"lol") | ||
| /// assert!( | ||
| /// map.contains_key(&123) | ||
| /// ); | ||
| /// assert!( | ||
| /// !map.contains_key(&321) | ||
| /// ); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V> | ||
| pub fn contains_key<BK>(&self, k: &BK) -> bool | ||
| where | ||
@@ -427,10 +412,123 @@ BK: Hash + Eq + ?Sized, | ||
| { | ||
| self.get(k).is_some() | ||
| } | ||
| /// Test whether a map is a submap of another map, meaning that | ||
| /// all keys in our map must also be in the other map, with the | ||
| /// same values. | ||
| /// | ||
| /// Use the provided function to decide whether values are equal. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_submap_by<B, RM, F>(&self, other: RM, mut cmp: F) -> bool | ||
| where | ||
| F: FnMut(&V, &B) -> bool, | ||
| RM: Borrow<HashMap<K, B, S>>, | ||
| { | ||
| self.iter() | ||
| .all(|(k, v)| other.borrow().get(k).map(|ov| cmp(v, ov)).unwrap_or(false)) | ||
| } | ||
| /// Test whether a map is a proper submap of another map, meaning | ||
| /// that all keys in our map must also be in the other map, with | ||
| /// the same values. To be a proper submap, ours must also contain | ||
| /// fewer keys than the other map. | ||
| /// | ||
| /// Use the provided function to decide whether values are equal. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool | ||
| where | ||
| F: FnMut(&V, &B) -> bool, | ||
| RM: Borrow<HashMap<K, B, S>>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_submap_by(other, cmp) | ||
| } | ||
| /// Test whether a map is a submap of another map, meaning that | ||
| /// all keys in our map must also be in the other map, with the | ||
| /// same values. | ||
| /// | ||
| /// Time: O(n log n) | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// # #[macro_use] extern crate im_rc as im; | ||
| /// # use im::hashmap::HashMap; | ||
| /// # fn main() { | ||
| /// let map1 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3}; | ||
| /// assert!(map1.is_submap(map2)); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn is_submap<RM>(&self, other: RM) -> bool | ||
| where | ||
| V: PartialEq, | ||
| RM: Borrow<Self>, | ||
| { | ||
| self.is_submap_by(other.borrow(), PartialEq::eq) | ||
| } | ||
| /// Test whether a map is a proper submap of another map, meaning | ||
| /// that all keys in our map must also be in the other map, with | ||
| /// the same values. To be a proper submap, ours must also contain | ||
| /// fewer keys than the other map. | ||
| /// | ||
| /// Time: O(n log n) | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// # #[macro_use] extern crate im_rc as im; | ||
| /// # use im::hashmap::HashMap; | ||
| /// # fn main() { | ||
| /// let map1 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3}; | ||
| /// assert!(map1.is_proper_submap(map2)); | ||
| /// | ||
| /// let map3 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map4 = hashmap!{1 => 1, 2 => 2}; | ||
| /// assert!(!map3.is_proper_submap(map4)); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn is_proper_submap<RM>(&self, other: RM) -> bool | ||
| where | ||
| V: PartialEq, | ||
| RM: Borrow<Self>, | ||
| { | ||
| self.is_proper_submap_by(other.borrow(), PartialEq::eq) | ||
| } | ||
| } | ||
| impl<K, V, S> HashMap<K, V, S> | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Clone, | ||
| S: BuildHasher, | ||
| { | ||
| /// Get a mutable iterator over the values of a hash map. | ||
| /// | ||
| /// Please note that the order is consistent between maps using | ||
| /// the same hasher, but no other ordering guarantee is offered. | ||
| /// Items will not come out in insertion order or sort order. | ||
| /// They will, however, come out in the same order every time for | ||
| /// the same map. | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn iter_mut(&mut self) -> IterMut<'_, K, V> { | ||
| let root = Ref::make_mut(&mut self.root); | ||
| match root.get_mut(hash_key(&*self.hasher, key), 0, key) { | ||
| None => None, | ||
| Some(&mut (_, ref mut value)) => Some(value), | ||
| IterMut { | ||
| it: NodeIterMut::new(root, self.size), | ||
| } | ||
| } | ||
| /// Test for the presence of a key in a hash map. | ||
| /// Get a mutable reference to the value for a key from a hash | ||
| /// map. | ||
| /// | ||
@@ -446,13 +544,10 @@ /// Time: O(log n) | ||
| /// let map = hashmap!{123 => "lol"}; | ||
| /// assert!( | ||
| /// map.contains_key(&123) | ||
| /// assert_eq!( | ||
| /// map.get(&123), | ||
| /// Some(&"lol") | ||
| /// ); | ||
| /// assert!( | ||
| /// !map.contains_key(&321) | ||
| /// ); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn contains_key<BK>(&self, k: &BK) -> bool | ||
| pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V> | ||
| where | ||
@@ -462,3 +557,7 @@ BK: Hash + Eq + ?Sized, | ||
| { | ||
| self.get(k).is_some() | ||
| let root = Ref::make_mut(&mut self.root); | ||
| match root.get_mut(hash_key(&*self.hasher, key), 0, key) { | ||
| None => None, | ||
| Some(&mut (_, ref mut value)) => Some(value), | ||
| } | ||
| } | ||
@@ -1064,97 +1163,2 @@ | ||
| } | ||
| /// Test whether a map is a submap of another map, meaning that | ||
| /// all keys in our map must also be in the other map, with the | ||
| /// same values. | ||
| /// | ||
| /// Use the provided function to decide whether values are equal. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_submap_by<B, RM, F>(&self, other: RM, mut cmp: F) -> bool | ||
| where | ||
| B: Clone, | ||
| F: FnMut(&V, &B) -> bool, | ||
| RM: Borrow<HashMap<K, B, S>>, | ||
| { | ||
| self.iter() | ||
| .all(|(k, v)| other.borrow().get(k).map(|ov| cmp(v, ov)).unwrap_or(false)) | ||
| } | ||
| /// Test whether a map is a proper submap of another map, meaning | ||
| /// that all keys in our map must also be in the other map, with | ||
| /// the same values. To be a proper submap, ours must also contain | ||
| /// fewer keys than the other map. | ||
| /// | ||
| /// Use the provided function to decide whether values are equal. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> bool | ||
| where | ||
| B: Clone, | ||
| F: FnMut(&V, &B) -> bool, | ||
| RM: Borrow<HashMap<K, B, S>>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_submap_by(other, cmp) | ||
| } | ||
| /// Test whether a map is a submap of another map, meaning that | ||
| /// all keys in our map must also be in the other map, with the | ||
| /// same values. | ||
| /// | ||
| /// Time: O(n log n) | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// # #[macro_use] extern crate im_rc as im; | ||
| /// # use im::hashmap::HashMap; | ||
| /// # fn main() { | ||
| /// let map1 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3}; | ||
| /// assert!(map1.is_submap(map2)); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn is_submap<RM>(&self, other: RM) -> bool | ||
| where | ||
| V: PartialEq, | ||
| RM: Borrow<Self>, | ||
| { | ||
| self.is_submap_by(other.borrow(), PartialEq::eq) | ||
| } | ||
| /// Test whether a map is a proper submap of another map, meaning | ||
| /// that all keys in our map must also be in the other map, with | ||
| /// the same values. To be a proper submap, ours must also contain | ||
| /// fewer keys than the other map. | ||
| /// | ||
| /// Time: O(n log n) | ||
| /// | ||
| /// # Examples | ||
| /// | ||
| /// ``` | ||
| /// # #[macro_use] extern crate im_rc as im; | ||
| /// # use im::hashmap::HashMap; | ||
| /// # fn main() { | ||
| /// let map1 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map2 = hashmap!{1 => 1, 2 => 2, 3 => 3}; | ||
| /// assert!(map1.is_proper_submap(map2)); | ||
| /// | ||
| /// let map3 = hashmap!{1 => 1, 2 => 2}; | ||
| /// let map4 = hashmap!{1 => 1, 2 => 2}; | ||
| /// assert!(!map3.is_proper_submap(map4)); | ||
| /// # } | ||
| /// ``` | ||
| #[inline] | ||
| #[must_use] | ||
| pub fn is_proper_submap<RM>(&self, other: RM) -> bool | ||
| where | ||
| V: PartialEq, | ||
| RM: Borrow<Self>, | ||
| { | ||
| self.is_proper_submap_by(other.borrow(), PartialEq::eq) | ||
| } | ||
| } | ||
@@ -1370,4 +1374,4 @@ | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: PartialEq + Clone, | ||
| K: Hash + Eq, | ||
| V: PartialEq, | ||
| S: BuildHasher, | ||
@@ -1383,4 +1387,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: PartialEq + Clone, | ||
| K: Hash + Eq, | ||
| V: PartialEq, | ||
| S: BuildHasher, | ||
@@ -1396,4 +1400,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Eq + Clone, | ||
| K: Hash + Eq, | ||
| V: Eq, | ||
| S: BuildHasher, | ||
@@ -1411,4 +1415,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Eq + Clone, | ||
| K: Hash + Eq, | ||
| V: Eq, | ||
| S: BuildHasher, | ||
@@ -1452,4 +1456,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Hash + Clone, | ||
| K: Hash + Eq, | ||
| V: Hash, | ||
| S: BuildHasher, | ||
@@ -1540,4 +1544,3 @@ { | ||
| BK: Hash + Eq + ?Sized, | ||
| K: Hash + Eq + Clone + Borrow<BK>, | ||
| V: Clone, | ||
| K: Hash + Eq + Borrow<BK>, | ||
| S: BuildHasher, | ||
@@ -1574,4 +1577,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone + Debug, | ||
| V: Debug + Clone, | ||
| K: Hash + Eq + Debug, | ||
| V: Debug, | ||
| S: BuildHasher, | ||
@@ -1591,4 +1594,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone + Debug, | ||
| V: Debug + Clone, | ||
| K: Hash + Eq + Debug, | ||
| V: Debug, | ||
| S: BuildHasher, | ||
@@ -1608,4 +1611,4 @@ { | ||
| where | ||
| K: Hash + Eq + Clone + Ord + Debug, | ||
| V: Debug + Clone, | ||
| K: Hash + Eq + Ord + Debug, | ||
| V: Debug, | ||
| S: BuildHasher, | ||
@@ -1693,3 +1696,3 @@ { | ||
| where | ||
| A: HashValue, | ||
| A: HashValue + Clone, | ||
| { | ||
@@ -1707,5 +1710,5 @@ type Item = A; | ||
| impl<A> ExactSizeIterator for ConsumingIter<A> where A: HashValue {} | ||
| impl<A> ExactSizeIterator for ConsumingIter<A> where A: HashValue + Clone {} | ||
| impl<A> FusedIterator for ConsumingIter<A> where A: HashValue {} | ||
| impl<A> FusedIterator for ConsumingIter<A> where A: HashValue + Clone {} | ||
@@ -1756,4 +1759,3 @@ // An iterator over the keys of a map. | ||
| where | ||
| K: Hash + Eq + Clone, | ||
| V: Clone, | ||
| K: Hash + Eq, | ||
| S: BuildHasher, | ||
@@ -1787,3 +1789,3 @@ { | ||
| // // Conversions | ||
| // Conversions | ||
@@ -1808,7 +1810,3 @@ impl<K, V, S> FromIterator<(K, V)> for HashMap<K, V, S> | ||
| impl<K, V, S> AsRef<HashMap<K, V, S>> for HashMap<K, V, S> | ||
| where | ||
| K: Clone, | ||
| V: Clone, | ||
| { | ||
| impl<K, V, S> AsRef<HashMap<K, V, S>> for HashMap<K, V, S> { | ||
| #[inline] | ||
@@ -1815,0 +1813,0 @@ fn as_ref(&self) -> &Self { |
+45
-38
@@ -113,3 +113,3 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| { | ||
@@ -293,3 +293,3 @@ type Key = A; | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| S: BuildHasher, | ||
@@ -315,2 +315,3 @@ { | ||
| } | ||
| /// Test if a value is part of a set. | ||
@@ -328,2 +329,34 @@ /// | ||
| /// Test whether a set is a subset of another set, meaning that | ||
| /// all values in our set must also be in the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| let o = other.borrow(); | ||
| self.iter().all(|a| o.contains(&a)) | ||
| } | ||
| /// Test whether a set is a proper subset of another set, meaning | ||
| /// that all values in our set must also be in the other set. A | ||
| /// proper subset must also be smaller than the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_subset(other) | ||
| } | ||
| } | ||
| impl<A, S> HashSet<A, S> | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| S: BuildHasher, | ||
| { | ||
| /// Get a mutable iterator over the values in a hash set. | ||
@@ -525,28 +558,2 @@ /// | ||
| } | ||
| /// Test whether a set is a subset of another set, meaning that | ||
| /// all values in our set must also be in the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| let o = other.borrow(); | ||
| self.iter().all(|a| o.contains(&a)) | ||
| } | ||
| /// Test whether a set is a proper subset of another set, meaning | ||
| /// that all values in our set must also be in the other set. A | ||
| /// proper subset must also be smaller than the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_subset(other) | ||
| } | ||
| } | ||
@@ -571,3 +578,3 @@ | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| S: BuildHasher + Default, | ||
@@ -582,3 +589,3 @@ { | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| S: BuildHasher + Default, | ||
@@ -620,3 +627,3 @@ { | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| S: BuildHasher + Default, | ||
@@ -726,3 +733,3 @@ { | ||
| where | ||
| A: Hash + Eq + Clone + Debug, | ||
| A: Hash + Eq + Debug, | ||
| S: BuildHasher, | ||
@@ -738,3 +745,3 @@ { | ||
| where | ||
| A: Hash + Eq + Clone + Debug, | ||
| A: Hash + Eq + Debug, | ||
| S: BuildHasher, | ||
@@ -750,3 +757,3 @@ { | ||
| where | ||
| A: Hash + Eq + Clone + Debug + Ord, | ||
| A: Hash + Eq + Debug + Ord, | ||
| S: BuildHasher, | ||
@@ -771,3 +778,3 @@ { | ||
| where | ||
| A: 'a + Clone, | ||
| A: 'a, | ||
| { | ||
@@ -785,5 +792,5 @@ type Item = &'a A; | ||
| impl<'a, A> ExactSizeIterator for Iter<'a, A> where A: Clone {} | ||
| impl<'a, A> ExactSizeIterator for Iter<'a, A> {} | ||
| impl<'a, A> FusedIterator for Iter<'a, A> where A: Clone {} | ||
| impl<'a, A> FusedIterator for Iter<'a, A> {} | ||
@@ -865,3 +872,3 @@ // A mutable iterator over the elements of a set. | ||
| where | ||
| A: Hash + Eq + Clone, | ||
| A: Hash + Eq, | ||
| S: BuildHasher, | ||
@@ -868,0 +875,0 @@ { |
+15
-6
@@ -22,3 +22,3 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| pub trait BTreeValue: Clone { | ||
| pub trait BTreeValue { | ||
| type Key; | ||
@@ -29,4 +29,7 @@ fn ptr_eq(&self, other: &Self) -> bool; | ||
| BK: Ord + ?Sized, | ||
| Self: Sized, | ||
| Self::Key: Borrow<BK>; | ||
| fn search_value(slice: &[Self], value: &Self) -> Result<usize, usize>; | ||
| fn search_value(slice: &[Self], value: &Self) -> Result<usize, usize> | ||
| where | ||
| Self: Sized; | ||
| fn cmp_keys<BK>(&self, other: &BK) -> Ordering | ||
@@ -182,2 +185,3 @@ where | ||
| where | ||
| A: Clone, | ||
| BK: Ord + ?Sized, | ||
@@ -427,3 +431,6 @@ A::Key: Borrow<BK>, | ||
| pub fn insert(&mut self, value: A) -> Insert<A> { | ||
| pub fn insert(&mut self, value: A) -> Insert<A> | ||
| where | ||
| A: Clone, | ||
| { | ||
| if self.keys.is_empty() { | ||
@@ -488,2 +495,3 @@ self.keys.push_back(value); | ||
| where | ||
| A: Clone, | ||
| BK: Ord + ?Sized, | ||
@@ -498,2 +506,3 @@ A::Key: Borrow<BK>, | ||
| where | ||
| A: Clone, | ||
| BK: Ord + ?Sized, | ||
@@ -1007,3 +1016,3 @@ A::Key: Borrow<BK>, | ||
| where | ||
| A: BTreeValue, | ||
| A: BTreeValue + Clone, | ||
| { | ||
@@ -1044,3 +1053,3 @@ type Item = A; | ||
| where | ||
| A: BTreeValue, | ||
| A: BTreeValue + Clone, | ||
| { | ||
@@ -1073,3 +1082,3 @@ fn next_back(&mut self) -> Option<Self::Item> { | ||
| impl<A: BTreeValue> ExactSizeIterator for ConsumingIter<A> {} | ||
| impl<A: BTreeValue + Clone> ExactSizeIterator for ConsumingIter<A> {} | ||
@@ -1076,0 +1085,0 @@ // DiffIter |
+10
-5
@@ -36,3 +36,3 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| pub trait HashValue: Clone { | ||
| pub trait HashValue { | ||
| type Key: Eq; | ||
@@ -194,2 +194,3 @@ | ||
| where | ||
| A: Clone, | ||
| BK: Eq + ?Sized, | ||
@@ -222,3 +223,6 @@ A::Key: Borrow<BK>, | ||
| pub fn insert(&mut self, hash: HashBits, shift: usize, value: A) -> Option<A> { | ||
| pub fn insert(&mut self, hash: HashBits, shift: usize, value: A) -> Option<A> | ||
| where | ||
| A: Clone, | ||
| { | ||
| let index = mask(hash, shift) as usize; | ||
@@ -286,2 +290,3 @@ if let Some(entry) = self.data.get_mut(index) { | ||
| where | ||
| A: Clone, | ||
| BK: Eq + ?Sized, | ||
@@ -606,3 +611,3 @@ A::Key: Borrow<BK>, | ||
| where | ||
| A: HashValue, | ||
| A: HashValue + Clone, | ||
| { | ||
@@ -654,5 +659,5 @@ type Item = (A, HashBits); | ||
| impl<A: HashValue> ExactSizeIterator for Drain<A> {} | ||
| impl<A: HashValue> ExactSizeIterator for Drain<A> where A: Clone {} | ||
| impl<A: HashValue> FusedIterator for Drain<A> {} | ||
| impl<A: HashValue> FusedIterator for Drain<A> where A: Clone {} | ||
@@ -659,0 +664,0 @@ impl<A: HashValue + fmt::Debug> fmt::Debug for Node<A> { |
+7
-0
@@ -600,2 +600,9 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| if !chunk.is_empty() { | ||
| if side == Left && chunk.len() < NODE_SIZE { | ||
| if let Entry::Nodes(ref mut size, _) = self.children { | ||
| if let Size::Size(value) = *size { | ||
| *size = Size::table_from_size(level, value); | ||
| } | ||
| } | ||
| } | ||
| self.push_size(side, chunk.len()); | ||
@@ -602,0 +609,0 @@ self.push_child_node(side, Ref::new(Node::from_chunk(0, chunk))); |
+49
-47
@@ -79,3 +79,3 @@ // This Source Code Form is subject to the terms of the Mozilla Public | ||
| #[cfg(not(has_specialisation))] | ||
| impl<A: Ord + Clone> BTreeValue for Value<A> { | ||
| impl<A: Ord> BTreeValue for Value<A> { | ||
| type Key = A; | ||
@@ -113,3 +113,3 @@ | ||
| #[cfg(has_specialisation)] | ||
| impl<A: Ord + Clone> BTreeValue for Value<A> { | ||
| impl<A: Ord> BTreeValue for Value<A> { | ||
| type Key = A; | ||
@@ -147,3 +147,3 @@ | ||
| #[cfg(has_specialisation)] | ||
| impl<A: Ord + Clone + Copy> BTreeValue for Value<A> { | ||
| impl<A: Ord + Copy> BTreeValue for Value<A> { | ||
| fn search_key<BK>(slice: &[Self], key: &BK) -> Result<usize, usize> | ||
@@ -295,3 +295,3 @@ where | ||
| where | ||
| A: Ord + Clone, | ||
| A: Ord, | ||
| { | ||
@@ -378,2 +378,33 @@ /// Get the smallest value in a set. | ||
| /// Test whether a set is a subset of another set, meaning that | ||
| /// all values in our set must also be in the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| let o = other.borrow(); | ||
| self.iter().all(|a| o.contains(&a)) | ||
| } | ||
| /// Test whether a set is a proper subset of another set, meaning | ||
| /// that all values in our set must also be in the other set. A | ||
| /// proper subset must also be smaller than the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_subset(other) | ||
| } | ||
| } | ||
| impl<A> OrdSet<A> | ||
| where | ||
| A: Ord + Clone, | ||
| { | ||
| /// Insert a value into a set. | ||
@@ -622,28 +653,2 @@ /// | ||
| /// Test whether a set is a subset of another set, meaning that | ||
| /// all values in our set must also be in the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| let o = other.borrow(); | ||
| self.iter().all(|a| o.contains(&a)) | ||
| } | ||
| /// Test whether a set is a proper subset of another set, meaning | ||
| /// that all values in our set must also be in the other set. A | ||
| /// proper subset must also be smaller than the other set. | ||
| /// | ||
| /// Time: O(n log n) | ||
| #[must_use] | ||
| pub fn is_proper_subset<RS>(&self, other: RS) -> bool | ||
| where | ||
| RS: Borrow<Self>, | ||
| { | ||
| self.len() != other.borrow().len() && self.is_subset(other) | ||
| } | ||
| /// Split a set into two, with the left hand set containing values | ||
@@ -730,3 +735,3 @@ /// which are smaller than `split`, and the right hand set | ||
| impl<A: Ord + Clone> PartialEq for OrdSet<A> { | ||
| impl<A: Ord> PartialEq for OrdSet<A> { | ||
| fn eq(&self, other: &Self) -> bool { | ||
@@ -738,5 +743,5 @@ Ref::ptr_eq(&self.root, &other.root) | ||
| impl<A: Ord + Eq + Clone> Eq for OrdSet<A> {} | ||
| impl<A: Ord + Eq> Eq for OrdSet<A> {} | ||
| impl<A: Ord + Clone> PartialOrd for OrdSet<A> { | ||
| impl<A: Ord> PartialOrd for OrdSet<A> { | ||
| fn partial_cmp(&self, other: &Self) -> Option<Ordering> { | ||
@@ -747,3 +752,3 @@ self.iter().partial_cmp(other.iter()) | ||
| impl<A: Ord + Clone> Ord for OrdSet<A> { | ||
| impl<A: Ord> Ord for OrdSet<A> { | ||
| fn cmp(&self, other: &Self) -> Ordering { | ||
@@ -754,3 +759,3 @@ self.iter().cmp(other.iter()) | ||
| impl<A: Ord + Clone + Hash> Hash for OrdSet<A> { | ||
| impl<A: Ord + Hash> Hash for OrdSet<A> { | ||
| fn hash<H>(&self, state: &mut H) | ||
@@ -766,6 +771,3 @@ where | ||
| impl<A> Default for OrdSet<A> | ||
| where | ||
| A: Ord + Clone, | ||
| { | ||
| impl<A> Default for OrdSet<A> { | ||
| fn default() -> Self { | ||
@@ -831,3 +833,3 @@ OrdSet::new() | ||
| impl<A: Ord + Clone + Debug> Debug for OrdSet<A> { | ||
| impl<A: Ord + Debug> Debug for OrdSet<A> { | ||
| fn fmt(&self, f: &mut Formatter) -> Result<(), Error> { | ||
@@ -850,3 +852,3 @@ f.debug_set().entries(self.iter()).finish() | ||
| where | ||
| A: 'a + Ord + Clone, | ||
| A: 'a + Ord, | ||
| { | ||
@@ -866,3 +868,3 @@ type Item = &'a A; | ||
| where | ||
| A: 'a + Ord + Clone, | ||
| A: 'a + Ord, | ||
| { | ||
@@ -874,3 +876,3 @@ fn next_back(&mut self) -> Option<Self::Item> { | ||
| impl<'a, A> ExactSizeIterator for Iter<'a, A> where A: 'a + Ord + Clone {} | ||
| impl<'a, A> ExactSizeIterator for Iter<'a, A> where A: 'a + Ord {} | ||
@@ -891,3 +893,3 @@ // A ranged iterator over the elements of a set. | ||
| where | ||
| A: 'a + Ord + Clone, | ||
| A: 'a + Ord, | ||
| { | ||
@@ -907,3 +909,3 @@ type Item = &'a A; | ||
| where | ||
| A: 'a + Ord + Clone, | ||
| A: 'a + Ord, | ||
| { | ||
@@ -938,3 +940,3 @@ fn next_back(&mut self) -> Option<Self::Item> { | ||
| where | ||
| A: 'a + Ord + Clone + PartialEq, | ||
| A: 'a + Ord + PartialEq, | ||
| { | ||
@@ -973,3 +975,3 @@ type Item = DiffItem<'a, A>; | ||
| where | ||
| A: 'a + Ord + Clone, | ||
| A: 'a + Ord, | ||
| { | ||
@@ -976,0 +978,0 @@ type Item = &'a A; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display