pub trait CheckedConversion {
    // Provided methods
    fn checked_from<T>(t: T) -> Option<Self>
       where Self: TryFrom<T> { ... }
    fn checked_into<T>(self) -> Option<T>
       where Self: TryInto<T> { ... }
}
Expand description

Convenience type to work around the highly unergonomic syntax needed to invoke the functions of overloaded generic traits, in this case TryFrom and TryInto.

Provided Methods§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>.

This just uses TryFrom internally but with this variant you can provide the destination type using turbofish syntax in case Rust happens not to assume the correct type.

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>.

This just uses TryInto internally but with this variant you can provide the destination type using turbofish syntax in case Rust happens not to assume the correct type.

Implementors§

§

impl<T> CheckedConversion for T