totems

Macro assert_contains

Source
macro_rules! assert_contains {
    ($collection:expr, $item:expr) => { ... };
}
Expand description

Asserts that an item is contained within a collection.

§Parameters

  • &collection A reference to a collection.
  • &item A reference to an item to compare to items in the collection.

§Dependencies

  • All content must implement Debug
  • &collection must implement IntoIterator.
  • item must implement PartialEq for the types in collection.

§Example

use totems::assert_contains;
let vec = vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
let x = 5;
assert_contains!(&vec, &x);

§Example Error Messages

thread 'main' panicked at 'assertion failed: (collection contains item)
       item: 2
 collection: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
', src/collections.rs:149:9