Skip to content

Commit ffd8320

Browse files
committed
[std][BTree] Fix behavior of ::append to match documentation and ::insert
1 parent 92c2bda commit ffd8320

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ where
107107
/// If two keys are equal, returns the key-value pair from the right source.
108108
fn next(&mut self) -> Option<(K, V)> {
109109
let (a_next, b_next) = self.0.nexts(|a: &(K, V), b: &(K, V)| K::cmp(&a.0, &b.0));
110-
b_next.or(a_next)
110+
match (a_next, b_next) {
111+
(Some((a_k, _)), Some((_, b_v))) => Some((a_k, b_v)),
112+
(Some(a), None) => Some(a),
113+
(None, Some(b)) => Some(b),
114+
(None, None) => None,
115+
}
111116
}
112117
}

0 commit comments

Comments
 (0)