Skip to content

Commit 922ccac

Browse files
committed
Clarify BTree range searching comments
1 parent d6eaea1 commit 922ccac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

library/alloc/src/collections/btree/search.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
9494
K: Borrow<Q>,
9595
R: RangeBounds<Q>,
9696
{
97-
// WARNING: Inlining these variables would be unsound (#81138)
97+
// It might be unsound to inline these variables if this logic changes (#81138).
9898
// We assume the bounds reported by `range` remain the same, but
9999
// an adversarial implementation could change between calls
100100
let (start, end) = (range.start_bound(), range.end_bound());
@@ -114,6 +114,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
114114
loop {
115115
let (lower_edge_idx, lower_child_bound) = self.find_lower_bound_index(lower_bound);
116116
let (upper_edge_idx, upper_child_bound) = self.find_upper_bound_index(upper_bound);
117+
// SAFETY: This panic is used for safety, so external impls can't be called here. The
118+
// comparison is done with integers for that reason.
117119
if lower_edge_idx > upper_edge_idx {
118120
panic!("Ord is ill-defined in BTreeMap range")
119121
}

0 commit comments

Comments
 (0)