Trait len_trait::len::Empty [] [src]

pub trait Empty {
    fn is_empty(&self) -> bool;
}

A trait for describing whether a collection is empty, i.e., its length is zero.

Checking whether a collection is empty should take a constant amount of time and space.

Required Methods

Returns whether the collection is empty.

Examples

use len_trait::Empty;

fn check_empty<C: ?Sized + Empty>(collection: &C) {
    assert!(collection.is_empty());
}

check_empty("");
check_empty(&[1, 2, 3][..0]);
check_empty(&"".to_string());

Implementors