Macro assertables::assert_set_subset
source · [−]macro_rules! assert_set_subset {
($left:expr, $right:expr $(,)?) => { ... };
($left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a set is a subset of another.
-
When true, return
Ok(()). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
Examples
let a = [1, 2];
let b = [1, 2, 3];
assert_set_subset!(&a, &b);
//-> ()
let a = [1, 2, 3];
let b = [1, 2];
assert_set_subset!(&a, &b);
//-> panic!
// assertion failed: `assert_set_subset!(left, right)`
// left: `[1, 2, 3]`,
// right: `[1, 2]`This macro has a second form where a custom message can be provided.
This implementation uses [HashSet] to count items.