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
32
33
34
35
use std::{
    fmt::{Debug, Display},
    ops::{Add, Sub},
};

pub mod numeric;
pub mod set;

#[derive(Debug)]
pub struct AddError {
    pub msg: String,
}

pub trait Work:
    Sized
    + Debug
    + Display
    + Add<Output = Result<Self, AddError>>
    + Sub<Output = Self>
    + PartialEq
    + PartialOrd
    + Clone
{
    type Type;

    fn new<A: Into<Self::Type>>(value: A) -> Self;
    fn zero() -> Self;
    fn min<'a>(a: &'a Self, b: &'a Self) -> &'a Self;

    fn parent_work_done_when(
        sub_work_done: Self,
        of_total_sub_work: Self,
        of_parent_work: Self,
    ) -> Self;
}