Macro assertables::assert_set_disjoint
source · macro_rules! assert_set_disjoint { ($a_collection:expr, $b_collection:expr $(,)?) => { ... }; ($a_collection:expr, $b_collection:expr, $($message:tt)+) => { ... }; }
Expand description
Assert a set is disjoint with another.
Pseudocode:
(collection1 into set) ⨃ (collection2 into set)
-
If true, return
()
. -
Otherwise, call
panic!
with a message and the values of the expressions with their debug representations.
§Examples
let a = [1, 2];
let b = [3, 4];
assert_set_disjoint!(&a, &b);
let a = [1, 2];
let b = [2, 3];
assert_set_disjoint!(&a, &b);
// assertion failed: `assert_set_disjoint!(a_collection, b_collection)`
// https://docs.rs/assertables/8.7.0/assertables/macro.assert_set_disjoint.html
// a label: `&a`,
// a debug: `[1, 2]`,
// b label: `&b`,
// b debug: `[2, 3]`,
// a: `{1, 2}`,
// b: `{2, 3}`
This implementation uses std::collections::BTreeSet
to count items and sort them.