finchers_core/
result.rs

1use self::sealed::Sealed;
2
3/// A helper trait enforcing that the type is `Result`.
4pub trait IsResult: Sealed {
5    /// The type of success value.
6    type Ok;
7
8    /// The type of error value.
9    type Err;
10
11    /// Consume itself and get the value of `Result`.
12    fn into_result(self) -> Result<Self::Ok, Self::Err>;
13}
14
15impl<T, E> IsResult for Result<T, E> {
16    type Ok = T;
17    type Err = E;
18
19    #[inline(always)]
20    fn into_result(self) -> Result<Self::Ok, Self::Err> {
21        self
22    }
23}
24
25mod sealed {
26    pub trait Sealed {}
27
28    impl<T, E> Sealed for Result<T, E> {}
29}