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
#[cfg(feature = "complex")]
use complex::{c32, c64};

use std::ops::{Add, Div, Mul, Neg, Sub};

/// A number.
pub trait Number: Add<Output=Self> +
                  Div<Output=Self> +
                  Mul<Output=Self> +
                  Neg<Output=Self> +
                  Sub<Output=Self> +
                  Copy + PartialEq {
}

macro_rules! implement(
    ($name:ty) => (
        impl Number for $name {
        }
    );
);

implement!(f32);
implement!(f64);

#[cfg(feature = "complex")]
implement!(c32);

#[cfg(feature = "complex")]
implement!(c64);