External Publication
Visit Post

Language vision regarding safety guarantees

Rust Internals [Unofficial] June 30, 2026
Source

ais523:

For the second requirement to hold, btree_map::CursorMut::insert_before_unchecked needs to be safe: otherwise, giving a BTreeMap a K with a broken Ord implementation is library UB, because it leads to an unsafe method being called without actually upholding its safety requirements.

This is wrong. It's OK for the function to exist and be unsafe. It's up to the caller to make sure they don't call it with invalid type / input combinations.

Discussion in the ATmosphere

Loading comments...