proc_bitfield/conv/
impls.rs

1use super::{Try, UnsafeFrom, UnsafeInto};
2
3impl<T> Try for Option<T> {
4    type Output = T;
5    type WithOutput<U> = Option<U>;
6
7    fn from_output(output: Self::Output) -> Self {
8        Some(output)
9    }
10}
11
12impl<T, E> Try for Result<T, E> {
13    type Output = T;
14    type WithOutput<U> = Result<U, E>;
15
16    fn from_output(output: Self::Output) -> Self {
17        Ok(output)
18    }
19}
20
21impl<T, U> UnsafeFrom<U> for T
22where
23    U: Into<T>,
24{
25    /// Calls `U::into(other)`.
26    ///
27    /// That is, this conversion is whatever the implementation of [`Into`]`<T> for U` chooses to
28    /// do.
29    #[inline]
30    unsafe fn unsafe_from(other: U) -> Self {
31        U::into(other)
32    }
33}
34
35impl<T, U> UnsafeInto<U> for T
36where
37    U: UnsafeFrom<T>,
38{
39    /// Calls `U::unsafe_from(self)`.
40    ///
41    /// That is, this conversion is whatever the implementation of [`UnsafeFrom`]`<T> for U`
42    /// chooses to do.
43    #[inline]
44    unsafe fn unsafe_into(self) -> U {
45        U::unsafe_from(self)
46    }
47}