@@ -247,7 +247,7 @@ impl<K: Clone + Ord, V: Clone> BTreeClone for BTreeMap<K, V> {
247
247
// replaces every key-value pair in `self`. Since `oiter` is in sorted
248
248
// order and the structure of the `BTreeMap` stays the same,
249
249
// the BTree invariants are maintained at the end of the loop
250
- while siter . front != siter. back {
250
+ while ! siter. is_empty ( ) {
251
251
if let Some ( ( ok, ov) ) = oiter. next ( ) {
252
252
// SAFETY: This is safe because the `siter.front != siter.back` check
253
253
// ensures that `siter` is nonempty
@@ -1764,7 +1764,7 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
1764
1764
type Item = ( & ' a K , & ' a mut V ) ;
1765
1765
1766
1766
fn next ( & mut self ) -> Option < ( & ' a K , & ' a mut V ) > {
1767
- if self . front == self . back {
1767
+ if self . is_empty ( ) {
1768
1768
None
1769
1769
} else {
1770
1770
unsafe {
@@ -1780,6 +1780,10 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
1780
1780
}
1781
1781
1782
1782
impl < ' a , K , V > RangeMut < ' a , K , V > {
1783
+ fn is_empty ( & self ) -> bool {
1784
+ self . front == self . back
1785
+ }
1786
+
1783
1787
unsafe fn next_unchecked ( & mut self ) -> ( & ' a mut K , & ' a mut V ) {
1784
1788
let handle = ptr:: read ( & self . front ) ;
1785
1789
@@ -1816,7 +1820,7 @@ impl<'a, K, V> RangeMut<'a, K, V> {
1816
1820
#[ stable( feature = "btree_range" , since = "1.17.0" ) ]
1817
1821
impl < ' a , K , V > DoubleEndedIterator for RangeMut < ' a , K , V > {
1818
1822
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 ( ) ) } }
1820
1824
}
1821
1825
}
1822
1826
0 commit comments