galvanic_assert::matchers

Function same_object

Source
pub fn same_object<'a, T>(expected: &'a T) -> Box<dyn Matcher<'a, T> + 'a>
where T: Debug + 'a,
Expand description

Matches if asserted value and the expected value are truely the same object.

The two values are the same if the reside at the same memory address.

#Examples

use galvanic_assert::matchers::*;
#[derive(Debug)]
struct Foo;
let foo1 = Foo;
let foo2 = Foo;

assert_that!(&foo1, same_object(&foo1));

assert_that!(
    assert_that!(&foo1, same_object(&foo2)),
    panics
);