@@ -68,13 +68,18 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
6868 /// of the range is different from the edge matching the upper bound, i.e.,
6969 /// the nearest node that has at least one key contained in the range.
7070 ///
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.
7475 ///
7576 /// If not found, returns an `Err` with the leaf edge matching the entire
7677 /// range.
7778 ///
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+ ///
7883 /// The result is meaningful only if the tree is ordered by key.
7984 pub fn search_tree_for_bifurcation < ' r , Q : ?Sized , R > (
8085 mut self ,
@@ -115,6 +120,10 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
115120 let ( lower_edge_idx, lower_child_bound) = self . find_lower_bound_index ( lower_bound) ;
116121 let ( upper_edge_idx, upper_child_bound) = self . find_upper_bound_index ( upper_bound) ;
117122 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.
118127 panic ! ( "Ord is ill-defined in BTreeMap range" )
119128 }
120129 if lower_edge_idx < upper_edge_idx {
0 commit comments