Expectation

Trait Expectation 

Source
pub trait Expectation<S: ?Sized> {
    // Required methods
    fn test(&mut self, subject: &S) -> bool;
    fn message(
        &self,
        expression: &Expression<'_>,
        actual: &S,
        inverted: bool,
        format: &DiffFormat,
    ) -> 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, inverted: bool, format: &DiffFormat, ) -> String

Forms a failure message for this expectation.

Implementors§

Source§

impl Expectation<&char> for IsAlphabetic

Source§

impl Expectation<&char> for IsAlphanumeric

Source§

impl Expectation<&char> for IsAscii

Source§

impl Expectation<&char> for IsControlChar

Source§

impl Expectation<&char> for IsDigit

Source§

impl Expectation<&char> for IsLowerCase

Source§

impl Expectation<&char> for IsUpperCase

Source§

impl Expectation<&char> for IsWhitespace

Source§

impl Expectation<bool> for IsFalse

Source§

impl Expectation<bool> for IsTrue

Source§

impl Expectation<char> for IsAlphabetic

Source§

impl Expectation<char> for IsAlphanumeric

Source§

impl Expectation<char> for IsAscii

Source§

impl Expectation<char> for IsControlChar

Source§

impl Expectation<char> for IsDigit

Source§

impl Expectation<char> for IsLowerCase

Source§

impl Expectation<char> for IsUpperCase

Source§

impl Expectation<char> for IsWhitespace

Source§

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

Available on crate feature float-cmp only.
Source§

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

Available on crate feature float-cmp only.
Source§

impl<M, E> Expectation<M> for MapContainsExactlyKeys<E>

Source§

impl<M, E> Expectation<M> for MapContainsKey<E>

Source§

impl<M, E> Expectation<M> for MapContainsKeys<E>

Source§

impl<M, E> Expectation<M> for MapContainsValue<E>

Source§

impl<M, E> Expectation<M> for MapContainsValues<E>

Source§

impl<M, E> Expectation<M> for MapDoesNotContainKeys<E>

Source§

impl<M, E> Expectation<M> for MapDoesNotContainValues<E>

Source§

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

Available on crate feature panic only.
Source§

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

Available on crate feature panic only.
Source§

impl<S> Expectation<S> for ErrorHasSource
where S: Error,

Source§

impl<S> Expectation<S> for ErrorHasSourceMessage
where S: Error,

Source§

impl<S> Expectation<S> for HasAtLeastCharCount<usize>

Source§

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

Source§

impl<S> Expectation<S> for HasAtMostCharCount<usize>

Source§

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

Source§

impl<S> Expectation<S> for HasCharCount<usize>

Source§

impl<S> Expectation<S> for HasCharCountGreaterThan<usize>

Source§

impl<S> Expectation<S> for HasCharCountLessThan<usize>

Source§

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

Source§

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

Source§

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

Source§

impl<S> Expectation<S> for HasPrecisionOf

Source§

impl<S> Expectation<S> for HasScaleOf

Source§

impl<S> Expectation<S> for IsANumber
where S: IsNanProperty + Debug,

Source§

impl<S> Expectation<S> for IsEmpty

Source§

impl<S> Expectation<S> for IsFinite

Source§

impl<S> Expectation<S> for IsInfinite

Source§

impl<S> Expectation<S> for IsInteger

Source§

impl<S> Expectation<S> for IsNegative
where S: SignumProperty + Debug,

Source§

impl<S> Expectation<S> for IsOne

Source§

impl<S> Expectation<S> for IsPositive
where S: SignumProperty + Debug,

Source§

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

Source§

impl<S> Expectation<S> for IsZero

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 StringMatches<'_>
where S: AsRef<str> + Debug,

Available on crate feature regex only.
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, A1: Expectation<S>> Expectation<S> for All<(Rec<A1>,)>

Source§

impl<S, A1: Expectation<S>> Expectation<S> for Any<(Rec<A1>,)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>, A11: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>, Rec<A11>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>, A11: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>, Rec<A11>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>, A11: Expectation<S>, A12: Expectation<S>> Expectation<S> for All<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>, Rec<A11>, Rec<A12>)>

Source§

impl<S, A1: Expectation<S>, A2: Expectation<S>, A3: Expectation<S>, A4: Expectation<S>, A5: Expectation<S>, A6: Expectation<S>, A7: Expectation<S>, A8: Expectation<S>, A9: Expectation<S>, A10: Expectation<S>, A11: Expectation<S>, A12: Expectation<S>> Expectation<S> for Any<(Rec<A1>, Rec<A2>, Rec<A3>, Rec<A4>, Rec<A5>, Rec<A6>, Rec<A7>, Rec<A8>, Rec<A9>, Rec<A10>, Rec<A11>, Rec<A12>)>

Source§

impl<S, E> Expectation<S> for HasDebugMessage<E>
where S: Debug, E: AsRef<str>,

Source§

impl<S, E> Expectation<S> for HasDisplayMessage<E>
where S: Display, E: AsRef<str>,

Source§

impl<S, E> Expectation<S> for IsAfter<E>
where S: PartialOrd<E> + Debug, E: 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 IsBefore<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for IsBetween<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 IsLessThan<E>
where S: PartialOrd<E> + Debug, E: Debug,

Source§

impl<S, E> Expectation<S> for Not<E>
where E: Invertible + Expectation<S>,

Source§

impl<S, E> Expectation<S> for Rec<E>
where E: Expectation<S>,

Source§

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

Source§

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

Source§

impl<S, R> Expectation<S> for HasCharCountInRange<R, usize>

Source§

impl<S, R> Expectation<S> for HasLengthInRange<R, usize>

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> Expectation<Option<T>> for IsNone
where T: Debug,

Source§

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

Source§

impl<T> Expectation<Vec<T>> for HasAtLeastNumberOfElements
where T: Debug,

Source§

impl<T> Expectation<Vec<T>> for HasSingleElement
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<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 IteratorContains<E>
where T: PartialEq<E> + Debug, E: Debug,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T, E> Expectation<Vec<T>> for IteratorStartsWith<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,

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,