patterns/bound.rs
1pub trait Bounded {
2 type Of: Copy;
3 const LO: Self::Of;
4 const HI: Self::Of;
5}
6
7pub trait HasMax {
8 type Of: Copy;
9 const MAX: Self::Of;
10}
11
12pub trait HasMin {
13 type Of: Copy;
14 const MIN: Self::Of;
15}
16
17impl<T: Bounded> HasMax for T {
18 type Of = <T as Bounded>::Of;
19 const MAX: Self::Of = <T as Bounded>::HI;
20}
21
22impl<T: Bounded> HasMin for T {
23 type Of = <T as Bounded>::Of;
24 const MIN: Self::Of = <T as Bounded>::LO;
25}