| 1 | //! # frequency |
| 2 | //! |
| 3 | //! A helper module for creating type-safe frequencies, while also allowing to create frequencies |
| 4 | //! from float and integer literals. |
| 5 | //! |
| 6 | //! # Examples |
| 7 | //! |
| 8 | //! ```ignore |
| 9 | //! fn main() { |
| 10 | //! use biquad::frequency::*; |
| 11 | //! |
| 12 | //! // Integer literals |
| 13 | //! let one_hz = 1.hz(); |
| 14 | //! let one_khz = 1.khz(); |
| 15 | //! let one_mhz = 1.mhz(); |
| 16 | //! |
| 17 | //! // Float literals |
| 18 | //! let one_hz = 1.0.dt(); |
| 19 | //! let ten_hz = 0.1.dt(); |
| 20 | //! } |
| 21 | //! ``` |
| 22 | //! |
| 23 | //! # Errors |
| 24 | //! |
| 25 | //! `Hertz::from_hz(...)` will error if the frequency is negative. |
| 26 | //! |
| 27 | //! # Panics |
| 28 | //! |
| 29 | //! `x.hz()`, `x.khz()`, `x.mhz()`, `x.dt()` will panic for `f32` if they are negative. |
| 30 | //! |
| 31 | |
| 32 | use craterust-analyzer cargo biquad 0.4.2 crate/::Errorsrust-analyzer cargo biquad 0.4.2 Errors#; |
| 33 | |
| 34 | /// Base type for frequency, everything is based on Hertz |
| 35 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 36 | pub struct Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<T>(T); |
| 37 | |
| 38 | /// Used to implement conversions to the Hertz struct |
| 39 | pub trait ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<T> { |
| 40 | /// From hertz |
| 41 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<T>; |
| 42 | |
| 43 | /// From kilohertz |
| 44 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<T>; |
| 45 | |
| 46 | /// From megahertz |
| 47 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<T>; |
| 48 | |
| 49 | /// From delta time (in seconds) |
| 50 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<T>; |
| 51 | } |
| 52 | |
| 53 | // ----------------------------------------------- |
| 54 | // f32 implementation |
| 55 | // ----------------------------------------------- |
| 56 | |
| 57 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f32> for f32 { |
| 58 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<Self>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 59 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(self).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 60 | } |
| 61 | |
| 62 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<Self>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 63 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().1_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 64 | } |
| 65 | |
| 66 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<Self>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 67 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Mul<Self>`]mul().1_000_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 68 | } |
| 69 | |
| 70 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<Self>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 71 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().self).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f32> for u32 { |
| 76 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f32>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 77 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(self as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 78 | } |
| 79 | |
| 80 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f32>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 81 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().1_000) as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 82 | } |
| 83 | |
| 84 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f32>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 85 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().1_000_000) as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 86 | } |
| 87 | |
| 88 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f32>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 89 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(1 as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().self as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f32> for i32 { |
| 94 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f32>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 95 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(self as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 96 | } |
| 97 | |
| 98 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f32>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 99 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().1_000) as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 100 | } |
| 101 | |
| 102 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f32>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 103 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().1_000_000) as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 104 | } |
| 105 | |
| 106 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f32>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 107 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f32>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(1 as f32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().self as f32).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | impl Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f32> { |
| 112 | pub fn from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_hz().(hz: f32) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`], Errorsrust-analyzer cargo biquad 0.4.2 Errors#> { |
| 113 | if hz rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().0.0 { |
| 114 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#(hz)) |
| 115 | } else { |
| 116 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorsrust-analyzer cargo biquad 0.4.2 Errors#::NegativeFrequencyrust-analyzer cargo biquad 0.4.2 Errors#NegativeFrequency#) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | pub fn from_dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]from_dt().(dt: f32) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`], Errorsrust-analyzer cargo biquad 0.4.2 Errors#> { |
| 121 | if dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f32][`PartialOrd<Self>`]gt().0.0 { |
| 122 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().dt)) |
| 123 | } else { |
| 124 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorsrust-analyzer cargo biquad 0.4.2 Errors#::NegativeFrequencyrust-analyzer cargo biquad 0.4.2 Errors#NegativeFrequency#) |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | pub fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f32>`]hz().(self) -> f32 { |
| 129 | self.0rust-analyzer cargo biquad 0.4.2 frequency/Hertz#0. |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | // ----------------------------------------------- |
| 134 | // f64 implementation |
| 135 | // ----------------------------------------------- |
| 136 | |
| 137 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f64> for f64 { |
| 138 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f64][`ToHertz<Self>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 139 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 140 | } |
| 141 | |
| 142 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f64][`ToHertz<Self>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 143 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 144 | } |
| 145 | |
| 146 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f64][`ToHertz<Self>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 147 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1_000_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 148 | } |
| 149 | |
| 150 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[f64][`ToHertz<Self>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 151 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().self).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f64> for f32 { |
| 156 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<f64>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 157 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 158 | } |
| 159 | |
| 160 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<f64>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 161 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 162 | } |
| 163 | |
| 164 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<f64>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 165 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().1_000_000.0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 166 | } |
| 167 | |
| 168 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[f32][`ToHertz<f64>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 169 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f64> for u32 { |
| 174 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f64>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 175 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 176 | } |
| 177 | |
| 178 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f64>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 179 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().1_000) as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 180 | } |
| 181 | |
| 182 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f64>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 183 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().1_000_000) as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 184 | } |
| 185 | |
| 186 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[u32][`ToHertz<f64>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 187 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(1 as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | impl ToHertzrust-analyzer cargo biquad 0.4.2 frequency/ToHertz#<f64> for i32 { |
| 192 | fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f64>`]hz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 193 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 194 | } |
| 195 | |
| 196 | fn khzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f64>`]khz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 197 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().1_000) as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 198 | } |
| 199 | |
| 200 | fn mhzrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f64>`]mhz().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 201 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().((self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().1_000_000) as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 202 | } |
| 203 | |
| 204 | fn dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[i32][`ToHertz<f64>`]dt().(self) -> Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 205 | Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#::<f64>::from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(1 as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().self as f64).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | impl Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#<f64> { |
| 210 | pub fn from_hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_hz().(hz: f64) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`], Errorsrust-analyzer cargo biquad 0.4.2 Errors#> { |
| 211 | if hz rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().0.0 { |
| 212 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#(hz)) |
| 213 | } else { |
| 214 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorsrust-analyzer cargo biquad 0.4.2 Errors#::NegativeFrequencyrust-analyzer cargo biquad 0.4.2 Errors#NegativeFrequency#) |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | pub fn from_dtrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]from_dt().(dt: f64) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`], Errorsrust-analyzer cargo biquad 0.4.2 Errors#> { |
| 219 | if dt rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().0.0 { |
| 220 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Hertzrust-analyzer cargo biquad 0.4.2 frequency/Hertz#(1.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Div<Self>`]div().dt)) |
| 221 | } else { |
| 222 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorsrust-analyzer cargo biquad 0.4.2 Errors#::NegativeFrequencyrust-analyzer cargo biquad 0.4.2 Errors#NegativeFrequency#) |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | pub fn hzrust-analyzer cargo biquad 0.4.2 frequency/impl#[`Hertz<f64>`]hz().(self) -> f64 { |
| 227 | self.0rust-analyzer cargo biquad 0.4.2 frequency/Hertz#0. |
| 228 | } |
| 229 | } |