Skip to main content

TryTo

Trait TryTo 

Source
pub trait TryTo<T> {
    type Error;

    // Required method
    fn try_to(self) -> Result<T, Self::Error>;
}
Expand description

Not all enums can have the std::convert::TryFrom trait derived on them because of rules around implementing foreign traits on foreign types.

This trait provides a similar interface that does not have this issue. It closely mimics the std::convert::TryInto trait.

Required Associated Types§

Required Methods§

Source

fn try_to(self) -> Result<T, Self::Error>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§