AssertHasDebugMessage

Trait AssertHasDebugMessage 

Source
pub trait AssertHasDebugMessage<E> {
    // Required methods
    fn has_debug_message(self, expected: E) -> Self;
    fn does_not_have_debug_message(self, expected: E) -> Self;
}
Expand description

Assert a type formatted into a debug string.

The subject’s type must implement Debug and the expected type must implement AsRef<str>.

§Examples

use asserting::prelude::*;

#[derive(Debug)]
struct Foo {
    hello: String,
}

let subject = Foo { hello: "World".into() };

assert_that!(&subject).has_debug_message("Foo { hello: \"World\" }");
assert_that!(&subject).does_not_have_debug_message("Bar { hello: \"World\" }");

Required Methods§

Source

fn has_debug_message(self, expected: E) -> Self

Verifies that a subject formatted for debugging results in the expected string.

§Examples
use asserting::prelude::*;

#[derive(Debug)]
struct Foo {
    hello: String,
}

let subject = Foo { hello: "World".into() };

assert_that!(subject).has_debug_message("Foo { hello: \"World\" }");
Source

fn does_not_have_debug_message(self, expected: E) -> Self

Verifies that a subject formatted for debugging does not result in the expected string.

§Examples
use asserting::prelude::*;

#[derive(Debug)]
struct Foo {
    hello: String,
}

let subject = Foo { hello: "World".into() };

assert_that!(subject).does_not_have_debug_message("Hello World");

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S, E, R> AssertHasDebugMessage<E> for Spec<'_, S, R>
where S: Debug, E: AsRef<str>, R: FailingStrategy,