Skip to main content

ExpectInto

Trait ExpectInto 

Source
pub trait ExpectInto {
    // Provided method
    fn expect_into<Dst: TryFrom<Self>>(self) -> Dst
       where Self: Sized { ... }
}
Expand description

Converts values with TryFrom and panics on failure.

The conversion delegates to [expect_into] and panics on failure. Its destination type can be inferred from the call context. Converts values through TryFrom and expects conversion to succeed.

The destination type is selected by the caller or inferred from context. Conversion failures are treated as violated program invariants.

Provided Methods§

Source

fn expect_into<Dst: TryFrom<Self>>(self) -> Dst
where Self: Sized,

Converts the value into Dst and returns the successful result.

The implementation delegates to the shared checked conversion helper. It discards the conversion error after using a fixed expectation message.

§Panics

Panics when Dst::try_from rejects the source value.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T> ExpectInto for T