@@ -68,13 +68,18 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
68
68
/// of the range is different from the edge matching the upper bound, i.e.,
69
69
/// the nearest node that has at least one key contained in the range.
70
70
///
71
- /// If found, returns an `Ok` with that node, the pair of edge indices in it
72
- /// delimiting the range, and the corresponding pair of bounds for
73
- /// continuing the search in the child nodes, in case the node is internal.
71
+ /// If found, returns an `Ok` with that node, the strictly ascending pair of
72
+ /// edge indices in the node delimiting the range, and the corresponding
73
+ /// pair of bounds for continuing the search in the child nodes, in case
74
+ /// the node is internal.
74
75
///
75
76
/// If not found, returns an `Err` with the leaf edge matching the entire
76
77
/// range.
77
78
///
79
+ /// As a diagnostic service, panics if the range specifies impossible bounds
80
+ /// or if it witnesses that the `Ord` implementation of `Q` violates total
81
+ /// order or is inconsistent with the `Ord` implementation of `K`.
82
+ ///
78
83
/// The result is meaningful only if the tree is ordered by key.
79
84
pub fn search_tree_for_bifurcation < ' r , Q : ?Sized , R > (
80
85
mut self ,
@@ -115,6 +120,10 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
115
120
let ( lower_edge_idx, lower_child_bound) = self . find_lower_bound_index ( lower_bound) ;
116
121
let ( upper_edge_idx, upper_child_bound) = self . find_upper_bound_index ( upper_bound) ;
117
122
if lower_edge_idx > upper_edge_idx {
123
+ // Since we already checked the range bounds, this can only
124
+ // happen if `Q: Ord` does not implement a total order or does
125
+ // not correspond to the `K: Ord` implementation that is used
126
+ // while populating the tree.
118
127
panic ! ( "Ord is ill-defined in BTreeMap range" )
119
128
}
120
129
if lower_edge_idx < upper_edge_idx {
0 commit comments