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
/// An angle expressed in radians.
pub struct Angle<T>(T);

impl<T> Angle<T> {
    /// Constructs the value from an angle specified in radians.
    pub fn from_radians(radians: T) -> Self {
        Self(radians)
    }

    /// Converts the value back into radians.
    pub fn into_radians(self) -> T {
        self.0
    }
}

impl Angle<f64> {
    /// Constructs the value from an angle specified in degrees.
    pub fn from_degrees(radians: f64) -> Self {
        Self(radians.to_radians())
    }
}

impl<T: Default> Default for Angle<T> {
    fn default() -> Self {
        Self(T::default())
    }
}