@@ -233,9 +233,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
233
233
}
234
234
235
235
if self . is_empty ( ) {
236
- // Ideally we'd call `BTreeMap::new` here, but that has the `K:
237
- // Ord` constraint, which this method lacks.
238
- BTreeMap { root : None , length : 0 }
236
+ BTreeMap :: new ( )
239
237
} else {
240
238
clone_subtree ( self . root . as_ref ( ) . unwrap ( ) . reborrow ( ) ) // unwrap succeeds because not empty
241
239
}
@@ -499,10 +497,7 @@ impl<K, V> BTreeMap<K, V> {
499
497
/// ```
500
498
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
501
499
#[ rustc_const_unstable( feature = "const_btree_new" , issue = "71835" ) ]
502
- pub const fn new ( ) -> BTreeMap < K , V >
503
- where
504
- K : Ord ,
505
- {
500
+ pub const fn new ( ) -> BTreeMap < K , V > {
506
501
BTreeMap { root : None , length : 0 }
507
502
}
508
503
@@ -522,7 +517,7 @@ impl<K, V> BTreeMap<K, V> {
522
517
/// ```
523
518
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
524
519
pub fn clear ( & mut self ) {
525
- * self = BTreeMap { root : None , length : 0 } ;
520
+ * self = BTreeMap :: new ( ) ;
526
521
}
527
522
528
523
/// Returns a reference to the value corresponding to the key.
@@ -1957,7 +1952,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
1957
1952
}
1958
1953
1959
1954
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1960
- impl < K : Ord , V > Default for BTreeMap < K , V > {
1955
+ impl < K , V > Default for BTreeMap < K , V > {
1961
1956
/// Creates an empty `BTreeMap`.
1962
1957
fn default ( ) -> BTreeMap < K , V > {
1963
1958
BTreeMap :: new ( )
0 commit comments