quil_rs/
units.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Cycles<T>(pub T);

#[derive(Clone, Copy, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Radians<T>(pub T);

impl From<Cycles<f64>> for Radians<f64> {
    fn from(cycles: Cycles<f64>) -> Self {
        Radians(cycles.0 * 2.0 * std::f64::consts::PI)
    }
}

impl From<Radians<f64>> for Cycles<f64> {
    fn from(radians: Radians<f64>) -> Self {
        Cycles(radians.0 / (2.0 * std::f64::consts::PI))
    }
}