pub trait IterableItemEqualityExpectations<'e, B, C>{
// Required methods
fn to_contain_equal_to(self, value: C) -> Self;
fn to_contain_equal_to_all_of(
self,
values: impl IntoIterator<Item = C>,
) -> Self;
fn to_be_equivalent_to(self, values: impl IntoIterator<Item = C>) -> Self;
fn to_be_equivalent_to_in_any_order(
self,
values: impl IntoIterator<Item = C>,
) -> Self;
}Expand description
Extension trait for equality expectations for iterables
Required Methods§
Sourcefn to_contain_equal_to(self, value: C) -> Self
fn to_contain_equal_to(self, value: C) -> Self
Expect an iterable to contain at least one value equal to another value
let haystack = vec!["bar", "foo", "foo"];
let needle = "foo";
expect(haystack).to_contain_equal_to(needle);asserts that haystack contains at least one item equal to needle
Sourcefn to_contain_equal_to_all_of(self, values: impl IntoIterator<Item = C>) -> Self
fn to_contain_equal_to_all_of(self, values: impl IntoIterator<Item = C>) -> Self
Expect an iterable to contain at least one value equal to another value
let haystack = vec!["apple", "orange", "pear", "apple", "peach"];
let needles = ["orange", "apple"];
expect(haystack).to_contain_equal_to_all_of(needles);asserts that haystack contains at least one item equal to each item in needles
Sourcefn to_be_equivalent_to(self, values: impl IntoIterator<Item = C>) -> Self
fn to_be_equivalent_to(self, values: impl IntoIterator<Item = C>) -> Self
Expect an iterable to be equivalent to another iterable
let a = vec!["apple", "orange", "pear", "apple", "peach"];
let b = ["apple", "orange", "pear", "apple", "peach"];
expect(a).to_be_equivalent_to(b);asserts that a contains exactly the same items in the same order as b
Sourcefn to_be_equivalent_to_in_any_order(
self,
values: impl IntoIterator<Item = C>,
) -> Self
fn to_be_equivalent_to_in_any_order( self, values: impl IntoIterator<Item = C>, ) -> Self
Expect an iterable to be equivalent to another iterable, ignoring the order of items
let a = vec!["apple", "orange", "pear", "apple", "peach"];
let b = ["orange", "peach", "apple", "apple", "pear"];
let c = ["peach", "apple", "pear", "orange", "apple"];
expect(a.clone()).to_be_equivalent_to_in_any_order(b);
expect(a).to_be_equivalent_to_in_any_order(c);
expect(b).to_be_equivalent_to_in_any_order(c);asserts that a contains exactly the same items in the same order as b
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.