cv_convert_fork/
traits.rs1pub use from::*;
2pub use try_from::*;
3
4mod try_from {
5 pub trait TryFromCv<T>
7 where
8 Self: Sized,
9 {
10 type Error;
11
12 fn try_from_cv(from: T) -> Result<Self, Self::Error>;
13 }
14
15 pub trait TryIntoCv<T> {
17 type Error;
18
19 fn try_into_cv(self) -> Result<T, Self::Error>;
20 }
21
22 impl<T, U> TryIntoCv<U> for T
23 where
24 U: TryFromCv<T>,
25 {
26 type Error = <U as TryFromCv<T>>::Error;
27
28 fn try_into_cv(self) -> Result<U, Self::Error> {
29 U::try_from_cv(self)
30 }
31 }
32}
33
34mod from {
35 pub trait FromCv<T> {
37 fn from_cv(from: T) -> Self;
38 }
39
40 pub trait IntoCv<T> {
42 fn into_cv(self) -> T;
43 }
44
45 impl<T, U> IntoCv<U> for T
46 where
47 U: FromCv<T>,
48 {
49 fn into_cv(self) -> U {
50 U::from_cv(self)
51 }
52 }
53}