rstmt_core/octave/traits/
convert.rs

1/*
2    Appellation: convert <module>
3    Contrib: @FL03
4*/
5use crate::Octave;
6
7/// A trait for converting a reference into an [`Octave`].
8pub trait AsOctave {
9    fn as_octave(&self) -> Octave;
10}
11/// A trait for converting a type into an [`Octave`].
12pub trait IntoOctave {
13    fn into_octave(self) -> Octave;
14}
15
16/*
17 ************* Implementations *************
18*/
19
20impl<T> AsOctave for T
21where
22    T: Clone + IntoOctave,
23{
24    fn as_octave(&self) -> Octave {
25        self.clone().into_octave()
26    }
27}
28
29impl<T> IntoOctave for T
30where
31    T: Into<Octave>,
32{
33    fn into_octave(self) -> Octave {
34        self.into()
35    }
36}