pub trait Compare<T> {
type Error;
// Required method
fn compare(&self, a: &T, b: &T) -> Result<Ordering, Self::Error>;
}
Expand description
General trait representing the ability to compare two values of some type.
Similar to core::cmp::Cmp
but with two key differences: the comparison is
fallible, and is provided by some external type implementing Compare
rather than the compared type itself.
This trait exists to support comparing Val
s with help from the
environment in which object handles are defined, and allowing for the
possibility of erroneous inputs like invalid object handles, as well as the
possibility of running over budget during the comparison. It is also used
in other places where comparison work has to be budgeted, such as inside
the host’s storage maps.