macro_rules! assertable_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, return Err with a message and the values of the expressions with their debug representations.

Examples

let a = [1, 2];
let b = [1, 2, 3];
let x = assertable_set_subset!(&a, &b);
//-> Ok(())
assert_eq!(x.unwrap(), ());

let a = [1, 2, 3];
let b = [1, 2];
let x = assertable_set_subset!(&a, &b);
//-> Err("…")
// assertable failed: `assertable_set_subset!(left, right)`
//   left: `[1, 2, 3]`,
//  right: `[1, 2]`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_set_subset!(left, right)`\n  left: `[1, 2, 3]`,\n right: `[1, 2]`".to_string());

This macro has a second form where a custom message can be provided.

This implementation uses [HashSet] to count items.