Skip to main content

abels_complex/
traits.rs

1use num_traits::*;
2
3pub trait Number:
4    FromI32 + Float + ConstZero + ConstOne + FloatConst + NumAssignOps + Euclid
5{
6}
7impl Number for f32 {}
8impl Number for f64 {}
9
10pub trait FromI32 {
11    fn from_i32(n: i32) -> Self;
12}
13impl FromI32 for f32 {
14    fn from_i32(n: i32) -> Self {
15        n as Self
16    }
17}
18impl FromI32 for f64 {
19    fn from_i32(n: i32) -> Self {
20        n as Self
21    }
22}