[][src]Macro totems::assert_any

macro_rules! assert_any {
    ($collection:expr, $predicate:expr) => { ... };
    ($collection:expr, $predicate:expr, $($arg:tt)+) => { ... };
}

Asserts that any item in a collection matches a predicate.

Parameters

  • &collection A reference to a collection.
  • predicate A closure or function that takes an item and returns a boolean.
  • description (optional) A string describing the predicate.

Dependencies

Example

use totems::assert_any;
let vec = vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19];
assert_any!(&vec, |&x| x > 0, "any > 0");

Example Error Messages

thread 'main' panicked at 'assertion failed: (any element of collection matches predicate)
  predicate: any < 0
 collection: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
', src/collections.rs:188:9