Language vision regarding safety guarantees
Rust Internals [Unofficial]
June 30, 2026
ais523:
For the second requirement to hold,
btree_map::CursorMut::insert_before_uncheckedneeds to be safe: otherwise, giving aBTreeMapaKwith a brokenOrdimplementation is library UB, because it leads to anunsafemethod 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