Ord
Ord is like PartialOrd, except that it doesn't allow the option of returning a "no relation" value; for any pair of values, either they are equal, or one is less than the other.
Ord is used by the compiler to implement the < (less than), > (greater than), <= (less than or equal), and >= (greater than or equal) comparison operators.
If a data type has the Ord trait, it has to also have the PartialOrd, Eq, and PartialEq traits. Like those traits, it can be manually implemented to enable comparisons between different data types, but we have to be very careful that the results returned by the various functions that are used to implement those traits agree with each other. When we derive the traits, we don't have to worry about that.
Here's ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access