pub trait BetterThanOperator<T> {
fn better_than(self: &Self, a: &T, b: &T) -> bool;
}
pub struct MinimizingOperator;
impl MinimizingOperator {
pub fn new() -> Self {
Self
}
}
impl<T> BetterThanOperator<T> for MinimizingOperator
where T: PartialOrd
{
fn better_than(self: &Self, a: &T, b: &T) -> bool {
a < b
}
}
pub struct MaximizingOperator;
impl MaximizingOperator {
pub fn new() -> Self {
Self
}
}
impl<T> BetterThanOperator<T> for MaximizingOperator
where T: PartialOrd
{
fn better_than(self: &Self, a: &T, b: &T) -> bool {
a > b
}
}