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
PartialOrd
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.
self
and other
) and is used by the `(lhs: T, rhs: T) -> bool
self
and other
) and is used by the >
operator.
self
and other
) and is used by
the >=
operator.