assertables/assert_set/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
//! Assert macros for comparing set collections.
//!
//! These macros help with comparison of set parameters, such as two arrays or
//! two vectors. where the item order does not matter, and the item count does
//! not matter. These macros convert their inputs into HashSet iterators.
//!
//! For eq & ne:
//!
//! * [`assert_set_eq!(collection1, collection2)`](macro@crate::assert_set_eq) ≈ set a = set b
//!
//! * [`assert_set_ne!(collection1, collection2)`](macro@crate::assert_set_ne) ≈ set a ≠ set b
//!
//! For subset & superset:
//!
//! * [`assert_set_subset!(collection1, collection2)`](macro@crate::assert_set_subset) ≈ set a ⊆ set b
//!
//! * [`assert_set_superset!(collection1, collection2)`](macro@crate::assert_set_superset) ≈ set a ⊇ set b
//!
//! For joint & disjoint:
//!
//! * [`assert_set_joint!(collection1, collection2)`](macro@crate::assert_set_joint) ≈ set a ∩ set b ≠ ∅
//!
//! * [`assert_set_disjoint!(collection1, collection2)`](macro@crate::assert_set_disjoint) ≈ set a ∩ set b = ∅
//!
//!
//! # Example
//!
//! ```rust
//! use assertables::*;
//! # fn main() {
//! let a = [1, 2];
//! let b = [2, 1];
//! assert_set_eq!(&a, &b);
//! # }
//! ```
#[macro_export]
macro_rules! assert_set_impl_prep {
($into_iterable:expr $(,)?) => {{
match (&$into_iterable) {
into_iterable => into_iterable.into_iter().collect()
}
}};
}
// Comparisons
pub mod assert_set_eq;
pub mod assert_set_ne;
// Overlaps
pub mod assert_set_joint;
pub mod assert_set_disjoint;
// Containers
pub mod assert_set_subset;
pub mod assert_set_superset;