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
use monoid::def_monoid_generics;

def_monoid_generics! {
    pub OpConcat[T, B] where [
        T: Clone,
        B: Clone + IntoIterator<Item = T> + FromIterator<T>,
    ] = (
        B,
        |x: &B, y: &B| x.clone().into_iter().chain(y.clone()).collect(),
        || None.into_iter().collect(),
    ),
}

#[cfg(test)]
mod tests {
    use monoid::{BinaryOp, Identity};

    use crate::*;

    #[test]
    fn sanity_check() {
        let concat = OpConcat::<i32, Vec<_>>::new();
        assert_eq!(concat.op(&vec![], &vec![]), vec![]);
        assert_eq!(concat.op(&vec![], &vec![3, 4]), vec![3, 4]);
        assert_eq!(concat.op(&vec![1, 2], &vec![]), vec![1, 2]);
        assert_eq!(concat.op(&vec![1, 2], &vec![3, 4]), vec![1, 2, 3, 4]);
        assert_eq!(concat.id(), vec![]);
    }
}