rstmt_core/freq/traits/
convert.rs

1/*
2    appellation: convert <module>
3    authors: @FL03
4*/
5use crate::freq::Frequency;
6
7/// [`AsFrequency`] is a trait enabling the conversion of a reference to a type into a
8/// [`Frequency`] instance.
9pub trait AsFrequency<T> {
10    /// Converts the current value into a [`Frequency`] instance.
11    fn as_frequency(&self) -> Frequency<T>;
12}
13/// The [`IntoFrequency`] trait consumes the value and converts it into a [`Frequency`].
14pub trait IntoFrequency<T> {
15    /// Converts the current value into a [`Frequency`] instance.
16    fn into_frequency(self) -> Frequency<T>;
17}
18
19/*
20 ************* Implementations *************
21*/
22impl<T> IntoFrequency<T> for T
23where
24    T: Into<Frequency<T>>,
25{
26    fn into_frequency(self) -> Frequency<T> {
27        self.into()
28    }
29}