pub unsafe trait TrustedSizedCollection { // Required method fn len(&self) -> usize; // Provided method fn is_empty(&self) -> bool { ... } }
A sized collection.
This trait can be trusted by unsafe code thanks to the invariants below.
Implementors of this trait must guarantee the following invariants:
len
is_empty
true
len == 0
collection.is_empty() == (collection.len() == 0)
Returns the number of elements in the collection.
let collection = vec![0; 5].into_par_index(); assert_eq!(collection.len(), 5);
Returns true if the collection has no elements in it.
Examples
let mut v = Vec::new(); { let collection = v.as_par_index(); assert!(collection.is_empty()); } v.push(42); { let collection = v.as_par_index(); assert!(!collection.is_empty()); }