minhash_rs/
min.rs

1pub trait Min {
2    fn set_min(&mut self, other: Self);
3
4    // Returns true if self is less than other.
5    fn is_min(&self, other: Self) -> bool;
6}
7
8impl Min for usize {
9    fn set_min(&mut self, other: Self) {
10        *self = (*self).min(other);
11    }
12
13    fn is_min(&self, other: Self) -> bool {
14        *self <= other
15    }
16}
17
18impl Min for u128 {
19    fn set_min(&mut self, other: Self) {
20        *self = (*self).min(other);
21    }
22
23    fn is_min(&self, other: Self) -> bool {
24        *self <= other
25    }
26}
27
28impl Min for u64 {
29    fn set_min(&mut self, other: Self) {
30        *self = (*self).min(other);
31    }
32
33    fn is_min(&self, other: Self) -> bool {
34        *self <= other
35    }
36}
37
38impl Min for u32 {
39    fn set_min(&mut self, other: Self) {
40        *self = (*self).min(other);
41    }
42
43    fn is_min(&self, other: Self) -> bool {
44        *self <= other
45    }
46}
47
48impl Min for u16 {
49    fn set_min(&mut self, other: Self) {
50        *self = (*self).min(other);
51    }
52
53    fn is_min(&self, other: Self) -> bool {
54        *self <= other
55    }
56}
57
58impl Min for u8 {
59    fn set_min(&mut self, other: Self) {
60        *self = (*self).min(other);
61    }
62
63    fn is_min(&self, other: Self) -> bool {
64        *self <= other
65    }
66}