Documentation of CursorMut::insert_after not right?

I think the documentation of https://doc.rust-lang.org/std/collections/btree_map/struct.CursorMut.html#method.insert_after is not quite right.

First, it says the function panics when given a bad key, but it has a Result with an Err type of UnorderedKeyError, which is presumably returned when the key is bad.

Second, where it says "current element " I think it should say "previous element". There is no "current element" for a Cursor, the Cursor points in-between two elements ( well... usually, unless the Cursor is at the start or end of the map ).

The same applies to insert_before.

The API was changed from panicking to Result in Rewrite the BTreeMap cursor API using gaps by Amanieu · Pull Request #118208 · rust-lang/rust · GitHub but the documentation was not updated, and is now wrong.

1 Like

I should have mentioned that CursorMutKey has the same issue.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.