macro_rules! assert_5th { ($tuple:expr, value == $val:expr) => { ... }; ($tuple:expr, value != $val:expr) => { ... }; ($tuple:expr, value < $val:expr) => { ... }; ($tuple:expr, value <= $val:expr) => { ... }; ($tuple:expr, value > $val:expr) => { ... }; ($tuple:expr, value >= $val:expr) => { ... }; }
Expand description
Asserts that the 5th item
in a tuple
has a relationship to some value.
§Parameters
&tuple
A reference to a tuple.&val
A reference to a value to compare to the 5th item.
§Dependencies
- All content must implement Debug
val
must implement PartialEq for the 5th type in the tuple to use==
or!=
.val
must implement PartialOrd for the 5th type in the tuple to use<
,<=
,>
,>=
.
§Example
use totems::assert_5th;
let tuple = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, "Hello");
let x = 6;
assert_5th!(&tuple, value == &x); // tuple.5 == x
assert_5th!(&tuple, value <= &x);
assert_5th!(&tuple, value >= &x);
assert_5th!(&tuple, value < &(x + 1));
assert_5th!(&tuple, value > &(x - 1));
§Example Error Messages
thread 'tuples::_05th::le_correct' panicked at 'assertion failed: (tuple.5 <= val)
val: 0
tuple.5: 1
', src/tuples.rs:2162:9