Empty

Trait Empty 

Source
pub trait Empty {
    // Required method
    fn is_empty(&self) -> bool;
}
Expand description

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§

Source

fn is_empty(&self) -> bool

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());

Implementations on Foreign Types§

Source§

impl Empty for str

Source§

fn is_empty(&self) -> bool

Source§

impl Empty for CString

Source§

fn is_empty(&self) -> bool

Source§

impl Empty for String

Source§

fn is_empty(&self) -> bool

Source§

impl Empty for CStr

Source§

fn is_empty(&self) -> bool

Source§

impl Empty for OsStr

Source§

fn is_empty(&self) -> bool

Source§

impl Empty for OsString

Source§

fn is_empty(&self) -> bool

Source§

impl<K: Eq + Hash, V> Empty for HashMap<K, V>

Source§

fn is_empty(&self) -> bool

Source§

impl<K: Ord, V> Empty for BTreeMap<K, V>

Source§

fn is_empty(&self) -> bool

Source§

impl<T> Empty for [T]

Source§

fn is_empty(&self) -> bool

Source§

impl<T> Empty for LinkedList<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T> Empty for VecDeque<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T> Empty for Vec<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: Eq + Hash> Empty for HashSet<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: Ord> Empty for BinaryHeap<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: Ord> Empty for BTreeSet<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: ?Sized + Empty> Empty for Box<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: ?Sized + Empty> Empty for Rc<T>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: ?Sized + Empty> Empty for Arc<T>

Source§

fn is_empty(&self) -> bool

Implementors§