macro_rules! assert_bag_superbag {
    ($left:expr, $right:expr $(,)?) => { ... };
    ($left:expr, $right:expr, $($arg:tt)+) => { ... };
}
Expand description

Assert a bag is equal to another.

  • When true, return ().

  • Otherwise, call panic! in order to print the values of the expressions with their debug representations.

Examples

let a = [1, 1, 1];
let b = [1, 1];
assert_bag_superbag!(&a, &b);
//-> ()

let a = [1, 1];
let b = [2, 2];
assert_bag_superbag!(&a, &b);
//-> panic!("…")
// assertion failed: `assert_bag_superbag!(left, right)`
//   left: `[1, 1]`,
//  right: `[2, 2]`
 
let a = [1, 1];
let b = [1, 1, 1];
assert_bag_superbag!(&a, &b);
//-> panic!("…")
// assertion failed: `assert_bag_superbag!(left, right)`
//   left: `[1, 1]`,
//  right: `[1, 1, 1]`

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

This implementation uses [HashMap] to count items.