pub struct Unknown;Expand description
Used with generic types in expectations where the concrete type is not relevant for the failure message.
This type implements the std format trait std::fmt::Debug and
std::fmt::Display which both format the value as “_”.
assert_that!(format!("{:?}", Unknown)).is_equal_to("_");
assert_that!(format!("{}", Unknown)).is_equal_to("_");§Examples
This type is used to implement the expectations
For example for implementing the function Expectation::message() for the
IsOk expectation for Result<T, E> the
concrete types for T and E are not relevant. The implementation of the
trait looks like this:
impl<T, E> Expectation<Result<T, E>> for IsOk
where
T: Debug,
E: Debug,
{
fn test(&mut self, subject: &Result<T, E>) -> bool {
subject.is_ok()
}
fn message(&self, expression: &Expression<'_>, actual: &Result<T, E>, _inverted: bool, _format: &DiffFormat) -> String {
format!(
"expected {expression} is {:?}\n but was: {actual:?}\n expected: {:?}",
Ok::<_, Unknown>(Unknown),
Ok::<_, Unknown>(Unknown),
)
}
}Trait Implementations§
impl Copy for Unknown
impl Eq for Unknown
impl StructuralPartialEq for Unknown
Auto Trait Implementations§
impl Freeze for Unknown
impl RefUnwindSafe for Unknown
impl Send for Unknown
impl Sync for Unknown
impl Unpin for Unknown
impl UnwindSafe for Unknown
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.