lt, le, gt, and ge methods of this trait can be called using the “, and
>= operators, respectively.
PartialOrd is not derivable, but can be implemented manually
Signature
Implementing PartialOrd
Here’s how to implement PartialOrd for a custom type. This example implements
comparison operations for a 2D point where points are compared based on their
squared Euclidean distance from the origin (0,0):
lt method needs to be implemented. The other comparison
operations (le, gt, ge) are automatically derived from lt. However,
you can override them for better performance if needed.
Trait functions
lt
Tests less than (forself and other) and is used by the `(lhs: T, rhs: T) -> bool
gt
Tests greater than (forself and other) and is used by the >
operator.
Signature
Examples
le
Tests greater than or equal to (forself and other) and is used by
the >= operator.