pub trait Len {
    // Required method
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Basic trait for anything that could have a length. Even if a lot of struct have a len() method in the standard library, to my knowledge this function is not included into any standard trait.

Required Methods§

source

fn len(&self) -> usize

Returns the number of elements in the collection, also referred to as its length.

Provided Methods§

source

fn is_empty(&self) -> bool

Return true if the collection has no element.

Implementations on Foreign Types§

source§

impl<T> Len for BTreeSet<T>

source§

fn len(&self) -> usize

source§

impl<T> Len for LinkedList<T>

source§

fn len(&self) -> usize

source§

impl<T, H> Len for HashSet<T, H>

source§

fn len(&self) -> usize

source§

impl<K, V, H> Len for HashMap<K, V, H>

source§

fn len(&self) -> usize

source§

impl<T> Len for VecDeque<T>

source§

fn len(&self) -> usize

source§

impl<T> Len for BinaryHeap<T>

source§

fn len(&self) -> usize

source§

impl<T> Len for Vec<T>

source§

fn len(&self) -> usize

source§

impl<K, V> Len for BTreeMap<K, V>

source§

fn len(&self) -> usize

Implementors§

source§

impl Len for RandomSampler

source§

impl Len for SequentialSampler

source§

impl<A1, A2, D1, D2> Len for NdarrayDataset<A1, A2, D1, D2>where A1: Clone, A2: Clone, D1: Dimension + RemoveAxis, D2: Dimension + RemoveAxis,

source§

impl<D, S, C> Len for DataLoader<D, S, C>where D: Dataset, S: Sampler, C: Collate<D::Sample>,

source§

impl<S: Sampler> Len for BatchSampler<S>