summaryrefslogtreecommitdiffstats
path: root/library/alloc/src/collections/btree/map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/alloc/src/collections/btree/map.rs')
-rw-r--r--library/alloc/src/collections/btree/map.rs66
1 files changed, 51 insertions, 15 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
index afdc99817..1f8a1ecba 100644
--- a/library/alloc/src/collections/btree/map.rs
+++ b/library/alloc/src/collections/btree/map.rs
@@ -1543,11 +1543,17 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
self.next_back()
}
- fn min(mut self) -> Option<(&'a K, &'a V)> {
+ fn min(mut self) -> Option<(&'a K, &'a V)>
+ where
+ (&'a K, &'a V): Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<(&'a K, &'a V)> {
+ fn max(mut self) -> Option<(&'a K, &'a V)>
+ where
+ (&'a K, &'a V): Ord,
+ {
self.next_back()
}
}
@@ -1612,11 +1618,17 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> {
self.next_back()
}
- fn min(mut self) -> Option<(&'a K, &'a mut V)> {
+ fn min(mut self) -> Option<(&'a K, &'a mut V)>
+ where
+ (&'a K, &'a mut V): Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<(&'a K, &'a mut V)> {
+ fn max(mut self) -> Option<(&'a K, &'a mut V)>
+ where
+ (&'a K, &'a mut V): Ord,
+ {
self.next_back()
}
}
@@ -1779,11 +1791,17 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> {
self.next_back()
}
- fn min(mut self) -> Option<&'a K> {
+ fn min(mut self) -> Option<&'a K>
+ where
+ &'a K: Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<&'a K> {
+ fn max(mut self) -> Option<&'a K>
+ where
+ &'a K: Ord,
+ {
self.next_back()
}
}
@@ -2008,11 +2026,17 @@ impl<'a, K, V> Iterator for Range<'a, K, V> {
self.next_back()
}
- fn min(mut self) -> Option<(&'a K, &'a V)> {
+ fn min(mut self) -> Option<(&'a K, &'a V)>
+ where
+ (&'a K, &'a V): Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<(&'a K, &'a V)> {
+ fn max(mut self) -> Option<(&'a K, &'a V)>
+ where
+ (&'a K, &'a V): Ord,
+ {
self.next_back()
}
}
@@ -2081,11 +2105,17 @@ impl<K, V, A: Allocator + Clone> Iterator for IntoKeys<K, V, A> {
self.next_back()
}
- fn min(mut self) -> Option<K> {
+ fn min(mut self) -> Option<K>
+ where
+ K: Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<K> {
+ fn max(mut self) -> Option<K>
+ where
+ K: Ord,
+ {
self.next_back()
}
}
@@ -2204,11 +2234,17 @@ impl<'a, K, V> Iterator for RangeMut<'a, K, V> {
self.next_back()
}
- fn min(mut self) -> Option<(&'a K, &'a mut V)> {
+ fn min(mut self) -> Option<(&'a K, &'a mut V)>
+ where
+ (&'a K, &'a mut V): Ord,
+ {
self.next()
}
- fn max(mut self) -> Option<(&'a K, &'a mut V)> {
+ fn max(mut self) -> Option<(&'a K, &'a mut V)>
+ where
+ (&'a K, &'a mut V): Ord,
+ {
self.next_back()
}
}
@@ -2985,7 +3021,7 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> {
})
}
- /// Returns a mutable reference to the of the element that the cursor is
+ /// Returns a mutable reference to the key of the element that the cursor is
/// currently pointing to.
///
/// This returns `None` if the cursor is currently pointing to the
@@ -3043,8 +3079,8 @@ impl<'a, K, V, A> CursorMut<'a, K, V, A> {
unsafe { self.root.reborrow() }
.as_mut()?
.borrow_mut()
- .first_leaf_edge()
- .next_kv()
+ .last_leaf_edge()
+ .next_back_kv()
.ok()?
.into_kv_valmut()
}