[−][src]Macro totems::assert_nth
Asserts that the nth item
in a collection
has a relationship to some value.
Parameters
&collection
A reference to a collection.position
The position in the collection (starts at 0).&val
A reference to a value to compare to the nth item.
Dependencies
- All content must implement Debug
&collection
must implement IntoIterator.val
must implement PartialEq for the types incollection
to use==
or!=
.val
must implement PartialOrd for the types incollection
to use<
,<=
,>
,>=
.
Example
use totems::assert_nth; let vec = vec![1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; let x = 5; assert_nth!(&vec, 2, value == &x); // vec[2] == x assert_nth!(&vec, 2, value <= &x); assert_nth!(&vec, 2, value >= &x); assert_nth!(&vec, 2, value < &(x + 1)); assert_nth!(&vec, 2, value > &(x - 1));
Example Error Messages
thread 'collections::nth::le_correct' panicked at 'assertion failed: (collection[3] <= item)
item: 5
collection[3]: 7
', src/collections.rs:388:9