Trait Expectation

Source
pub trait Expectation<S: ?Sized> {
    // Required methods
    fn test(&mut self, subject: &S) -> bool;
    fn message(&self, expression: Expression<'_>, actual: &S) -> String;
}
Expand description

An expectation defines a test for a property of the asserted subject.

It requires two methods: a test() method and a message() method. The test() method is called to verify whether an actual subject meets the expected property. In case the test of the expectation fails the message() method is called to form an expectation specific failure message.

Required Methods§

Source

fn test(&mut self, subject: &S) -> bool

Verifies whether the actual subject fulfills the expected property.

Source

fn message(&self, expression: Expression<'_>, actual: &S) -> String

Forms a failure message for this expectation.

Implementors§

Source§

impl Expectation<bool> for IsFalse

Source§

impl Expectation<bool> for IsTrue

Source§

impl Expectation<f32> for IsCloseTo<f32, F32Margin>

Source§

impl Expectation<f32> for IsNotCloseTo<f32, F32Margin>

Source§

impl Expectation<f64> for IsCloseTo<f64, F64Margin>

Source§

impl Expectation<f64> for IsNotCloseTo<f64, F64Margin>

Source§

impl<S> Expectation<Code<S>> for DoesNotPanic
where S: FnOnce(),

Source§

impl<S> Expectation<Code<S>> for DoesPanic
where S: FnOnce(),

Source§

impl<S> Expectation<S> for HasLength<usize>
where S: LengthProperty + Debug,

Source§

impl<S> Expectation<S> for HasLengthInRange<usize>
where S: LengthProperty + Debug,

Source§

impl<S> Expectation<S> for IsEmpty

Source§

impl<S> Expectation<S> for IsNotEmpty

Source§

impl<S> Expectation<S> for StringContains<&str>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringContains<char>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringContains<String>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringContainsAnyOf<&[char]>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringEndsWith<&str>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringEndsWith<char>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringEndsWith<String>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringStartWith<&str>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringStartWith<char>
where S: AsRef<str> + Debug,

Source§

impl<S> Expectation<S> for StringStartWith<String>
where S: AsRef<str> + Debug,

Source§

impl<S, E> Expectation<S> for IsAtLeast<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsAtMost<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsEqualTo<E>
where S: PartialEq<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsGreaterThan<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsInRange<E>
where S: PartialOrd<E> + Debug, E: PartialOrd<S> + Debug,

Source§

impl<S, E> Expectation<S> for IsLessThan<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsNotEqualTo<E>
where S: PartialEq<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsNotInRange<E>
where S: PartialOrd<E> + Debug, E: PartialOrd<S> + Debug,

Source§

impl<S, P> Expectation<S> for Predicate<P>
where P: Fn(&S) -> bool,

Source§

impl<S, const N: usize> Expectation<S> for StringContainsAnyOf<&[char; N]>
where S: AsRef<str> + Debug,

Source§

impl<S, const N: usize> Expectation<S> for StringContainsAnyOf<[char; N]>
where S: AsRef<str> + Debug,

Source§

impl<T> Expectation<Option<T>> for IsNone
where T: Debug,

Source§

impl<T> Expectation<Option<T>> for IsSome
where T: Debug,

Source§

impl<T, E> Expectation<Option<T>> for HasValue<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Result<T, E>> for IsErr
where T: Debug, E: Debug,

Source§

impl<T, E> Expectation<Result<T, E>> for IsOk
where T: Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContains<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsAllInOrder<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsAllOf<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsAnyOf<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsExactly<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsExactlyInAnyOrder<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsOnly<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsOnlyOnce<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterContainsSequence<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterEndsWith<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E> Expectation<Vec<T>> for IterStartsWith<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

impl<T, E, X> Expectation<Result<T, E>> for HasError<X>
where T: Debug, E: PartialEq<X> + Debug, X: Debug,

Source§

impl<T, E, X> Expectation<Result<T, E>> for HasValue<X>
where T: PartialEq<X> + Debug, E: Debug, X: Debug,