1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::{UnsafeFrom, UnsafeInto};

impl<T, U> UnsafeFrom<U> for T
where
    T: From<U>,
{
    /// Calls `T::from(other)`.
    ///
    /// That is, this conversion is whatever the implementation of [`From`]`<U> for T` chooses to
    /// do.
    #[inline]
    unsafe fn unsafe_from(other: U) -> Self {
        Self::from(other)
    }
}

impl<T, U> UnsafeInto<U> for T
where
    U: UnsafeFrom<T>,
{
    /// Calls `U::unsafe_from(self)`.
    ///
    /// That is, this conversion is whatever the implementation of [`UnsafeFrom`]`<T> for U`
    /// chooses to do.
    #[inline]
    unsafe fn unsafe_into(self) -> U {
        U::unsafe_from(self)
    }
}