Function googletest::matchers::empty

source ·
pub fn empty<T: Debug + ?Sized>() -> impl Matcher<ActualT = T>
where for<'a> &'a T: IntoIterator,
Expand description

Matches an empty container.

T can be any container such that &T implements IntoIterator. For instance, T can be a common container like Vec and HashSet.

let value: Vec<i32> = vec![];
verify_that!(value, empty())?;
let value: HashSet<i32> = HashSet::new();
verify_that!(value, empty())?;

One can also check whether a slice is empty by dereferencing it:

let value: &[u32] = &[];
verify_that!(*value, empty())?;