tierkreis_core/
prelude.rs1use std::convert::Infallible;
4
5pub trait TryFrom<T>: Sized {
7    type Error;
9
10    fn try_from(value: T) -> Result<Self, Self::Error>;
12}
13
14pub trait TryInto<T>: Sized {
16    type Error;
18
19    fn try_into(self) -> Result<T, Self::Error>;
21}
22
23impl<T, U> TryInto<U> for T
24where
25    U: TryFrom<T>,
26{
27    type Error = U::Error;
28
29    fn try_into(self) -> Result<U, U::Error> {
30        <U as TryFrom<_>>::try_from(self)
31    }
32}
33
34impl<T> TryFrom<T> for T {
35    type Error = Infallible;
36
37    fn try_from(value: T) -> Result<Self, Self::Error> {
38        Ok(value)
39    }
40}
41
42impl TryFrom<i64> for u32 {
43    type Error = <u32 as std::convert::TryFrom<i64>>::Error;
44
45    fn try_from(value: i64) -> Result<Self, Self::Error> {
46        std::convert::TryFrom::try_from(value)
47    }
48}