macro_rules! assert_not_contains {
    ($container:expr, $containee:expr $(,)?) => { ... };
    ($container:expr, $containee:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a container is a match for an expression.

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

Examples

// Return Ok
let a = "foogoo";
let b = "zz";
assert_not_contains!(a, b);
//-> ()

// Panic with error message
let result = panic::catch_unwind(|| {
let a = "foogoo";
let b = "oo";
assert_not_contains!(a, b);
//-> panic!
});
assert!(result.is_err());
let actual = result.unwrap_err().downcast::<String>().unwrap().to_string();
let expect = concat!(
    "assertion failed: `assert_not_contains!(container, containee)`\n",
    " container label: `a`,\n",
    " container debug: `\"foogoo\"`,\n",
    " containee label: `b`,\n",
    " containee debug: `\"oo\"`"
);
assert_eq!(actual, expect);