You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some traits like TotalOrd and TotalEq have invariants (like a < b || a == b || a > b for all a and b for TotalOrd). These can be stated in documentation but not enforced by the compiler or in the type system.
Some algorithms (e.g. a sort, or a data structure) may wish to rely on these stated invariants in a way that means a violation could be memory unsafe. E.g. a highly-optimised sort might run out of bounds when a comparison function is incorrect in exactly the right (well, wrong) way. Being safe in the face of incorrectness can come at the cost of efficiency by being forced to use a slower algorithm, or perform bounds checks etc.