reflexo_typst2vec/
cast.rs1pub trait FromTypst<T>: Sized {
2 fn from_typst(value: T) -> Self;
3}
4
5pub trait IntoTypst<T>: Sized {
6 fn into_typst(self) -> T;
7}
8
9impl<T, U> IntoTypst<U> for T
10where
11 U: FromTypst<T>,
12{
13 fn into_typst(self) -> U {
14 U::from_typst(self)
15 }
16}
17
18pub trait TryFromTypst<T>: Sized {
19 type Error;
20
21 fn try_from_typst(value: T) -> Result<Self, Self::Error>;
22}
23
24pub trait TryIntoTypst<T>: Sized {
25 type Error;
26
27 fn try_into_typst(self) -> Result<T, Self::Error>;
28}
29
30impl<T, U> TryIntoTypst<U> for T
31where
32 U: TryFromTypst<T>,
33{
34 type Error = U::Error;
35
36 fn try_into_typst(self) -> Result<U, Self::Error> {
37 U::try_from_typst(self)
38 }
39}