diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 8fb9198a7cb25..c26388a1db1f0 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -500,11 +500,8 @@ impl BTreeMap { /// assert!(a.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn clear(&mut self) - where - K: Ord, - { - *self = BTreeMap::new(); + pub fn clear(&mut self) { + *self = BTreeMap { root: None, length: 0 }; } /// Returns a reference to the value corresponding to the key. @@ -1227,10 +1224,7 @@ impl BTreeMap { /// ``` #[inline] #[unstable(feature = "map_into_keys_values", issue = "75294")] - pub fn into_keys(self) -> IntoKeys - where - K: Ord, - { + pub fn into_keys(self) -> IntoKeys { IntoKeys { inner: self.into_iter() } } @@ -1253,10 +1247,7 @@ impl BTreeMap { /// ``` #[inline] #[unstable(feature = "map_into_keys_values", issue = "75294")] - pub fn into_values(self) -> IntoValues - where - K: Ord, - { + pub fn into_values(self) -> IntoValues { IntoValues { inner: self.into_iter() } } } diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 78edf11d3934b..1993c6e047d48 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1711,12 +1711,19 @@ fn test_ord_absence() { fn map(mut map: BTreeMap) { map.is_empty(); map.len(); + map.clear(); map.iter(); map.iter_mut(); map.keys(); map.values(); map.values_mut(); - map.into_iter(); + if true { + map.into_values(); + } else if true { + map.into_iter(); + } else { + map.into_keys(); + } } fn map_debug(mut map: BTreeMap) { @@ -1726,7 +1733,13 @@ fn test_ord_absence() { format!("{:?}", map.keys()); format!("{:?}", map.values()); format!("{:?}", map.values_mut()); - format!("{:?}", map.into_iter()); + if true { + format!("{:?}", map.into_iter()); + } else if true { + format!("{:?}", map.into_keys()); + } else { + format!("{:?}", map.into_values()); + } } fn map_clone(mut map: BTreeMap) { diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 8072762d87917..c619b5bf8edd1 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -457,10 +457,7 @@ impl BTreeSet { /// assert!(v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn clear(&mut self) - where - T: Ord, - { + pub fn clear(&mut self) { self.map.clear() } diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 79e469eb0db8b..3762af7236af2 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -641,9 +641,10 @@ fn test_send() { #[allow(dead_code)] fn test_ord_absence() { - fn set(set: BTreeSet) { + fn set(mut set: BTreeSet) { set.is_empty(); set.len(); + set.clear(); set.iter(); set.into_iter(); }