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
use super::op_add;
use super::op_min;
use super::super::traits::action;
use super::super::traits::additive;
use super::super::traits::binop;
use super::super::traits::max;
use std::fmt::Debug;
use std::ops::Add;

use action::MonoidAction;
use additive::{AddAssoc, Zero};
use binop::Magma;
use max::Max;
use op_add::OpAdd;
use op_min::OpMin;

#[derive(Clone, Copy, Debug, Default)]
pub struct OpAddOnOpMin<T> {
    op_add: OpAdd<T>,
    op_min: OpMin<T>,
}

impl<T: Ord + Eq + Add<Output = T> + AddAssoc + Zero + Max + Sized> MonoidAction
    for OpAddOnOpMin<T>
{
    type Operand = OpMin<T>;
    type Operator = OpAdd<T>;
    fn operand(&self) -> &Self::Operand { &self.op_min }
    fn operator(&self) -> &Self::Operator { &self.op_add }
    fn act(&self, x: T, op: T) -> T { self.op_add.op(x, op) }
}