assert_empty

Macro assert_empty 

Source
macro_rules! assert_empty {
    ($expression:expr) => { ... };
    ($expression:expr, $($arg:tt)+) => { ... };
}
Expand description

Asserts that expression is empty using is_empty.

§Uses

Assertions are always checked in both debug and release builds, and cannot be disabled. See debug_assert_empty! for assertions that are not enabled in release builds by default.

§Custom messages

This macro has a second form, where a custom panic message can be provided with or without arguments for formatting. See std::fmt for syntax for this form.

§Examples

use testutils::assert_empty;
let vec: Vec<usize> = vec![];

assert_empty!(vec);

// With custom messages
assert_empty!(vec, "Expecting {:?} to be empty", vec);

A non-empty value will cause a panic:

use testutils::assert_empty;
let vec: Vec<usize> = vec![1];

assert_empty!(vec); // Will panic
//