Skip to main content

OptionAssertion

Trait OptionAssertion 

Source
pub trait OptionAssertion<T> {
    // Required method
    fn contain(self, expected: &T) -> Self;
}
Expand description

Containment assertion for Option.

This lives on a trait rather than being an inherent method for the same coherence reason as [CollectionAssertion]: an inherent contain on Assertion<Option<T>> would clash with the inherent contain from the impl<T: AsRef<str>> Assertion<T> string assertions, because coherence cannot rule out a future AsRef<str> impl for Option<_>.

Required Methods§

Source

fn contain(self, expected: &T) -> Self

Asserts that the Option is Some and contains the expected value

§Examples
use fluent_assertions::*;
Some(5).should().contain(&5);

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§