macro_rules! assert_variant_at_idx {
    ($indexable:expr, $idx:expr, $variant:pat_param $( | $others:pat)* => $e:expr, $fmt:expr $(, $args:tt)* $(,)?) => { ... };
    ($indexable:expr, $idx:expr, $variant:pat_param $( | $others:pat)* => $e:expr $(,)?) => { ... };
    ($indexable:expr, $idx:expr, $variant:pat_param $( | $others:pat)*, $fmt:expr $(, $args:tt)* $(,)?) => { ... };
    ($indexable:expr, $idx:expr, $variant:pat_param $( | $others:pat)* $(,)?) => { ... };
}
Expand description

Asserts the value at a particular index of an expression evaluating to a type implementing the Index trait. This macro is effectively a thin wrapper around assert_variant that will pretty-print the entire indexable value if the assertion fails.

This macro is particularly useful when failure to assert a single value in a Vec requires more context to debug the failure.

§Examples

let v = vec![0, 2];
// Success
assert_variant_at_idx!(v, 0, 0);
// Panics: "unexpected variant at 0 in v:
// [
//   0,
//   2,
// ]"
assert_variant_at_idx!(v, 0, 2);