diff options
| author | dylni <46035563+dylni@users.noreply.github.com> | 2021-03-15 00:26:41 -0400 |
|---|---|---|
| committer | dylni <46035563+dylni@users.noreply.github.com> | 2021-03-15 00:26:41 -0400 |
| commit | 922ccacc93b75260045d4871f029c8be4cb17d36 (patch) | |
| tree | c6e17165e8b99b3bb66772bd3c1f0c13d3b6e124 /library | |
| parent | d6eaea1c8860adb5302d2fbaad409e36585ab217 (diff) | |
| download | rust-922ccacc93b75260045d4871f029c8be4cb17d36.tar.gz rust-922ccacc93b75260045d4871f029c8be4cb17d36.zip | |
Clarify BTree range searching comments
Diffstat (limited to 'library')
| -rw-r--r-- | library/alloc/src/collections/btree/search.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/library/alloc/src/collections/btree/search.rs b/library/alloc/src/collections/btree/search.rs index f376b3cde02..e599800c3c7 100644 --- a/library/alloc/src/collections/btree/search.rs +++ b/library/alloc/src/collections/btree/search.rs @@ -94,7 +94,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea K: Borrow<Q>, R: RangeBounds<Q>, { - // WARNING: Inlining these variables would be unsound (#81138) + // It might be unsound to inline these variables if this logic changes (#81138). // We assume the bounds reported by `range` remain the same, but // an adversarial implementation could change between calls 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 loop { let (lower_edge_idx, lower_child_bound) = self.find_lower_bound_index(lower_bound); let (upper_edge_idx, upper_child_bound) = self.find_upper_bound_index(upper_bound); + // SAFETY: This panic is used for safety, so external impls can't be called here. The + // comparison is done with integers for that reason. if lower_edge_idx > upper_edge_idx { panic!("Ord is ill-defined in BTreeMap range") } |
