pub fn subset_of<ExpectedT>(superset: ExpectedT) -> SubsetOfMatcher<ExpectedT>Expand description
Matches a container all of whose items are in the given container
superset.
The element type ElementT must implement PartialEq to allow element
comparison.
ActualT and ExpectedT can each be any container which
implements IntoIterator. For instance, T can be a common container like
&Vec or arrays. They need not be the same container type.
let value = vec![1, 2, 3];
verify_that!(value, subset_of([&1, &2, &3, &4]))?; // Passes
let array_value = [1, 2, 3];
verify_that!(array_value, subset_of([1, 2, 3, 4]))?; // Passes
verify_that!(value, subset_of([&1, &2]))?; // Fails: 3 is not in the superset
let value: HashSet<i32> = [1, 2, 3].into();
verify_that!(value, subset_of([&1, &2, &3]))?; // PassesItem multiplicity in both the actual and expected containers is ignored:
let value: Vec<i32> = vec![0, 0, 1];
verify_that!(value, subset_of([&0, &1]))?; // Passes
verify_that!(value, subset_of([&0, &1, &1]))?; // PassesA note on performance: This matcher uses a naive algorithm with a worst-case runtime proportional to the product of the sizes of the actual and expected containers as well as the time to check equality of each pair of items. It should not be used on especially large containers.