1use super::super::traits::binop;
4use super::super::traits::max;
5
6use std::fmt::Debug;
7
8use binop::{Associative, Commutative, Identity, Magma};
9use max::Max;
10
11#[derive(Clone, Copy, Debug, Eq, PartialEq)]
17pub enum OpMin<T> {
18 OpMinV,
19 _Marker(T),
20}
21pub use OpMin::OpMinV;
22
23impl<T> Default for OpMin<T> {
24 fn default() -> Self { OpMinV }
25}
26
27impl<T> Magma for OpMin<T>
28where
29 T: Ord + Eq + Sized,
30{
31 type Set = T;
32 fn op(&self, x: Self::Set, y: Self::Set) -> Self::Set { x.min(y) }
33}
34impl<T> Identity for OpMin<T>
35where
36 T: Ord + Eq + Sized + Max,
37{
38 fn id(&self) -> Self::Set { <T as Max>::max() }
39}
40
41impl<T> Associative for OpMin<T> where T: Ord + Eq + Sized {}
42impl<T> Commutative for OpMin<T> where T: Ord + Eq + Sized {}