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
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());
Implementors
impl<T> Empty for [T]
impl Empty for str
impl<T: ?Sized + Empty> Empty for Box<T>
impl<T: ?Sized + Empty> Empty for Rc<T>
impl<T: ?Sized + Empty> Empty for Arc<T>
impl<K: Ord, V> Empty for BTreeMap<K, V>
impl<T: Ord> Empty for BTreeSet<T>
impl<T: Ord> Empty for BinaryHeap<T>
impl<T> Empty for LinkedList<T>
impl Empty for String
impl<T> Empty for Vec<T>
impl<T> Empty for VecDeque<T>
impl Empty for CStr
impl Empty for CString
impl Empty for OsStr
impl Empty for OsString
impl<K: Eq + Hash, V> Empty for HashMap<K, V>
impl<T: Eq + Hash> Empty for HashSet<T>