macro_rules! assert_bag_subbag { ($a_collection:expr, $b_collection:expr $(,)?) => { ... }; ($a_collection:expr, $b_collection:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a bag is a subbag of another.
Pseudocode:
(collection1 into bag) ⊂ (collection2 into bag)
-
If true, return
(). -
Otherwise, call
panic!in order to print the values of the expressions with their debug representations.
§Examples
use assertables::*;
let a = [1, 1];
let b = [1, 1, 1];
assert_bag_subbag!(&a, &b);
// This will panic
let a = [1, 1, 1];
let b = [1, 1];
assert_bag_subbag!(&a, &b);
// assertion failed: `assert_bag_subbag!(a_collection, b_collection)`
// https://docs.rs/assertables/8.16.0/assertables/macro.assert_bag_subbag.html
// a label: `&a`,
// a debug: `[1, 1, 1]`,
// b label: `&b`,
// b debug: `[1, 1]`,
// a: `{1: 3}`,
// b: `{1: 2}`This implementation uses std::collections::BTreeMap to count items and sort them.