@@ -233,9 +233,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
233233 }
234234
235235 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 ( )
239237 } else {
240238 clone_subtree ( self . root . as_ref ( ) . unwrap ( ) . reborrow ( ) ) // unwrap succeeds because not empty
241239 }
@@ -499,10 +497,7 @@ impl<K, V> BTreeMap<K, V> {
499497 /// ```
500498 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
501499 #[ 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 > {
506501 BTreeMap { root : None , length : 0 }
507502 }
508503
@@ -522,7 +517,7 @@ impl<K, V> BTreeMap<K, V> {
522517 /// ```
523518 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
524519 pub fn clear ( & mut self ) {
525- * self = BTreeMap { root : None , length : 0 } ;
520+ * self = BTreeMap :: new ( ) ;
526521 }
527522
528523 /// Returns a reference to the value corresponding to the key.
@@ -1957,7 +1952,7 @@ impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
19571952}
19581953
19591954#[ 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 > {
19611956 /// Creates an empty `BTreeMap`.
19621957 fn default ( ) -> BTreeMap < K , V > {
19631958 BTreeMap :: new ( )
0 commit comments