pub trait ComparableMetric:
Any
+ Send
+ Sync {
// Required methods
fn value(&self) -> f64;
fn compare(&self, other: &dyn ComparableMetric) -> Ordering;
fn as_any(&self) -> &dyn Any;
}Expand description
Trait for appraisal metrics that can be compared.
Implementers define how their values should be compared to determine
which investment option is preferable through the compare method.
Required Methods§
Sourcefn compare(&self, other: &dyn ComparableMetric) -> Ordering
fn compare(&self, other: &dyn ComparableMetric) -> Ordering
Compares this metric with another of the same type.
Returns Ordering::Less if self is better than other,
Ordering::Greater if other is better, or Ordering::Equal
if they are approximately equal.
§Panics
Panics if other is not the same concrete type as self.