rstmt_core/freq/
impl_freq_repr.rs

1/*
2    appellation: impl_freq_repr <module>
3    authors: @FL03
4*/
5use crate::freq::{Frequency, RawFrequency};
6#[cfg(feature = "complex")]
7use num_complex::{Complex, ComplexFloat};
8
9impl<T> Frequency<&T>
10where
11    T: RawFrequency,
12{
13    #[inline]
14    /// returns a new instance of the [`Frequency`] with a cloned instance of the current value.
15    pub fn cloned(&self) -> Frequency<T>
16    where
17        T: Clone,
18    {
19        Frequency(self.0.clone())
20    }
21
22    /// returns a new instance of the [`Frequency`] with a copied instance of the current value.
23    pub const fn copied(&self) -> Frequency<T>
24    where
25        T: Copy,
26    {
27        Frequency(*self.0)
28    }
29}
30
31impl<T> Frequency<&mut T>
32where
33    T: RawFrequency,
34{
35    #[inline]
36    /// returns a new instance of the [`Frequency`] with a cloned instance of the current value.
37    pub fn cloned(&self) -> Frequency<T>
38    where
39        T: Clone,
40    {
41        Frequency(self.0.clone())
42    }
43
44    /// returns a new instance of the [`Frequency`] with a copied instance of the current value.
45    pub const fn copied(&self) -> Frequency<T>
46    where
47        T: Copy,
48    {
49        Frequency(*self.0)
50    }
51}
52
53#[cfg(feature = "complex")]
54impl<T> Frequency<Complex<T>>
55where
56    T: RawFrequency,
57    Complex<T>: ComplexFloat<Real = T> + RawFrequency,
58{
59    /// returns the complex conjugate of the frequency value
60    pub fn conj(&self) -> Frequency<Complex<T>>
61    where
62        T: Copy,
63    {
64        self.map(|v| v.conj())
65    }
66}