Function xpct::try_into

source ·
pub fn try_into<'a, In, Out>() -> Matcher<'a, In, Out>where
    In: 'a,
    Out: TryFrom<In> + 'a,
    <Out as TryFrom<In>>::Error: Error + Send + Sync + 'static,
Expand description

Fallibly convert the input value via TryFrom/TryInto.

This does the same thing as Assertion::try_into.

This matcher always succeeds as long as TryFrom::try_from returns Ok, even when negated. Therefore negating it has no effect.

Examples

use xpct::{expect, equal, try_into};

expect!(41u64)
    .to(try_into::<_, u32>())
    .to(equal(41u32));