rstmt_core/notes/traits/convert.rs
1/*
2 appellation: convert <module>
3 authors: @FL03
4*/
5use crate::notes::Aspn;
6
7/// The [`AsAspn`] trait is used to convert a reference into a [`Aspn`]
8pub trait AsAspn {
9 fn as_aspn(&self) -> Aspn;
10}
11/// A trait for converting a type into a [`Aspn`]
12pub trait IntoAspn {
13 fn into_aspn(self) -> Aspn;
14}
15
16/*
17 ************* Implementations *************
18*/
19impl<T> AsAspn for T
20where
21 T: Clone + IntoAspn,
22{
23 fn as_aspn(&self) -> Aspn {
24 self.clone().into_aspn()
25 }
26}
27
28impl<T> IntoAspn for T
29where
30 T: Into<Aspn>,
31{
32 fn into_aspn(self) -> Aspn {
33 self.into()
34 }
35}