parse_frequency/
num_traits.rs1use super::Frequency;
2use std::ops::{Div, Mul, Rem};
3
4impl Mul for Frequency {
5 type Output = Self;
6
7 fn mul(self, rhs: Self) -> Self::Output {
8 Frequency(self.0 * rhs.0)
9 }
10}
11
12impl Div for Frequency {
13 type Output = Self;
14
15 fn div(self, rhs: Self) -> Self::Output {
16 Frequency(self.0 / rhs.0)
17 }
18}
19
20impl Rem for Frequency {
21 type Output = Self;
22
23 fn rem(self, rhs: Self) -> Self::Output {
24 Frequency(self.0 % rhs.0)
25 }
26}
27
28impl num_traits::Zero for Frequency {
29 fn zero() -> Self {
30 Frequency::ZERO
31 }
32
33 fn is_zero(&self) -> bool {
34 self.0 == 0
35 }
36}
37
38impl num_traits::One for Frequency {
39 fn one() -> Self {
40 Frequency::HERTZ
41 }
42}
43
44impl num_traits::Num for Frequency {
45 type FromStrRadixErr = std::num::ParseIntError;
46
47 fn from_str_radix(s: &str, _radix: u32) -> Result<Self, Self::FromStrRadixErr> {
48 s.parse::<u64>().map(Frequency)
49 }
50}