@@ -247,7 +247,7 @@ impl<K: Clone + Ord, V: Clone> BTreeClone for BTreeMap<K, V> {
247247 // replaces every key-value pair in `self`. Since `oiter` is in sorted
248248 // order and the structure of the `BTreeMap` stays the same,
249249 // the BTree invariants are maintained at the end of the loop
250- while siter . front != siter. back {
250+ while ! siter. is_empty ( ) {
251251 if let Some ( ( ok, ov) ) = oiter. next ( ) {
252252 // SAFETY: This is safe because the `siter.front != siter.back` check
253253 // ensures that `siter` is nonempty
@@ -1764,7 +1764,7 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
17641764 type Item = ( & ' a K , & ' a mut V ) ;
17651765
17661766 fn next ( & mut self ) -> Option < ( & ' a K , & ' a mut V ) > {
1767- if self . front == self . back {
1767+ if self . is_empty ( ) {
17681768 None
17691769 } else {
17701770 unsafe {
@@ -1780,6 +1780,10 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
17801780}
17811781
17821782impl < ' a , K , V > RangeMut < ' a , K , V > {
1783+ fn is_empty ( & self ) -> bool {
1784+ self . front == self . back
1785+ }
1786+
17831787 unsafe fn next_unchecked ( & mut self ) -> ( & ' a mut K , & ' a mut V ) {
17841788 let handle = ptr:: read ( & self . front ) ;
17851789
@@ -1816,7 +1820,7 @@ impl<'a, K, V> RangeMut<'a, K, V> {
18161820#[ stable( feature = "btree_range" , since = "1.17.0" ) ]
18171821impl < ' a , K , V > DoubleEndedIterator for RangeMut < ' a , K , V > {
18181822 fn next_back ( & mut self ) -> Option < ( & ' a K , & ' a mut V ) > {
1819- if self . front == self . back { None } else { unsafe { Some ( self . next_back_unchecked ( ) ) } }
1823+ if self . is_empty ( ) { None } else { unsafe { Some ( self . next_back_unchecked ( ) ) } }
18201824 }
18211825}
18221826
0 commit comments