Function ref_equal

Source
pub fn ref_equal<A>(a: &(impl AsRef<A> + Debug), b: &(impl AsRef<A> + Debug))
where A: Debug + PartialEq + ?Sized,
Expand description

Assert that they share the same AsRef somewhere.

ยงExample

use common_testing::assert;

#[test]
fn test_1() {
  let my_string = "abc";

  // When there is more than one AsRef possible, say which one.
  assert::ref_equal::<str>(&my_string, &"abc");
  assert::ref_equal::<str>(&my_string.to_string(), &"abc".to_string());

  // When there is only one AsRef possible, the types are inferred.
  assert::ref_equal(&my_string, &b"abc");
}