~ruther/ctu-fee-eoa

ref: 96e498675423c4bad7fa358efb37fe26a6dc1563 ctu-fee-eoa/env/src/comparison/mod.rs -rw-r--r-- 619 bytes
96e49867 — Rutherther feat: add initializers, ZeroInitializer, RandomInitializer a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
    }
}