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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use std::fmt::Display;
use std::ops::Add;
use std::ops::AddAssign;
use std::ops::Div;
use std::ops::DivAssign;
use std::ops::Mul;
use std::ops::MulAssign;
use std::ops::Rem;
use std::ops::Sub;
use std::ops::SubAssign;

use super::Half;
use super::NumTrampolene;

use ::num_traits::identities::{One, Zero};

/// A common number trait.
///
/// A number is a collection of the traits below.
/// But you cannot get them all together in Rust.
/// So we have had to build our own.
///
/// The Points, Rects, and Shapes, all use these traits.
pub trait Num:
    Add<Self, Output = Self>
    + AddAssign
    + Sub<Self, Output = Self>
    + SubAssign
    + Mul<Self, Output = Self>
    + MulAssign
    + Div<Self, Output = Self>
    + DivAssign
    + Rem<Self, Output = Self>
    + PartialOrd
    + Display
    + Copy
    + PartialEq
    + NumTrampolene
    + Half
    + Zero
    + One
    + Sized
{
}

/// You might be wondering 'what does this do?'
/// So am I!
///
/// I think it's saying *'the trait above really does exists, and is
/// implemented, for `U`'*. This applies for cases where `U` matches the `Num`
/// trait.
impl<U> Num for U where
    U: Add<Self, Output = Self>
        + AddAssign
        + Sub<Self, Output = Self>
        + SubAssign
        + Mul<Self, Output = Self>
        + MulAssign
        + Div<Self, Output = Self>
        + DivAssign
        + Rem<Self, Output = Self>
        + PartialOrd
        + Display
        + Copy
        + PartialEq
        + NumTrampolene
        + Half
        + Zero
        + One
        + Sized
{
}