/// `TryFrom` trait; the trait is currently experimental in Rust, so use a custom implementation for
/// now.
pub trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
type Error;
/// Performs the conversion.
fn try_from(T) -> Result<Self, Self::Error>;
}
/// `TryInto` trait; the trait is currently experimental in Rust, so use a custom implementation for
/// now.
pub trait TryInto<T>: Sized {
/// The type returned in the event of a conversion error.
type Error;
/// Performs the conversion.
fn try_into(self) -> Result<T, Self::Error>;
}
impl<T, U> TryInto<U> for T
where U: TryFrom<T>
{
type Error = U::Error;
fn try_into(self) -> Result<U, U::Error> {
U::try_from(self)
}
}