autd3_core/common/freq/
int.rs

1use super::{Freq, Hz, kHz};
2
3impl core::ops::Mul<Hz> for u32 {
4    type Output = Freq<u32>;
5
6    fn mul(self, _rhs: Hz) -> Self::Output {
7        Self::Output { freq: self }
8    }
9}
10
11impl core::ops::Mul<kHz> for u32 {
12    type Output = Freq<u32>;
13
14    fn mul(self, _rhs: kHz) -> Self::Output {
15        Self::Output { freq: self * 1000 }
16    }
17}
18
19impl core::ops::Mul<Freq<u32>> for u32 {
20    type Output = Freq<u32>;
21
22    fn mul(self, rhs: Freq<u32>) -> Self::Output {
23        Self::Output {
24            freq: self * rhs.freq,
25        }
26    }
27}
28
29#[cfg(test)]
30mod tests {
31    use super::*;
32
33    #[test]
34    fn ctor() {
35        assert_eq!(Freq { freq: 200 }, 200 * Hz);
36        assert_eq!(Freq { freq: 2000 }, 2 * kHz);
37    }
38
39    #[test]
40    fn ops() {
41        assert_eq!(200 * Hz, 2 * (100 * Hz));
42    }
43}