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§
Sourcefn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
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.
Sourcefn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".