pub trait WrappingInto<T>: Sized {
fn into_wrapping(self) -> T;
}
pub trait WrappingFrom<T>: Sized {
fn from_wrapping(_: T) -> Self;
}
impl<T, U> WrappingInto<U> for T
where
U: WrappingFrom<T>,
{
fn into_wrapping(self) -> U {
U::from_wrapping(self)
}
}
pub trait LossyInto<T>: Sized {
fn into_lossy(self) -> T;
}
pub trait LossyFrom<T>: Sized {
fn from_lossy(_: T) -> Self;
}
impl<T, U> LossyInto<U> for T
where
U: LossyFrom<T>,
{
fn into_lossy(self) -> U {
U::from_lossy(self)
}
}
pub unsafe trait UncheckedInto<T>: Sized {
unsafe fn into_unchecked(self) -> T;
}
pub unsafe trait UncheckedFrom<T>: Sized {
unsafe fn from_unchecked(_: T) -> Self;
}
unsafe impl<T, U> UncheckedInto<U> for T
where
U: UncheckedFrom<T>,
{
unsafe fn into_unchecked(self) -> U {
U::from_unchecked(self)
}
}