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
/// A Scalar type that can be converted to a component of a Vector
///
/// It does not necessarily have to be a lossless conversion, because the geometry module focuses
/// on ease of use and speed over extreme precision
pub trait Scalar: Copy {
    /// Cast the scalar into an f32, which is how a Vector represents it
    fn float(self) -> f32;
}

impl Scalar for u8 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for u16 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for u32 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for i8 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for i16 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for i32 {
    fn float(self) -> f32 {
        self as f32
    }
}
impl Scalar for f32 {
    fn float(self) -> f32 {
        self
    }
}