mckernant1_tools::iter::counting

Trait EachCount

Source
pub trait EachCount {
    type Item;

    // Required methods
    fn each_count(self) -> HashMap<Self::Item, u64>
       where Self::Item: Hash + Eq;
    fn each_count_by<K>(
        self,
        selector: fn(_: Self::Item) -> K,
    ) -> HashMap<K, u64>
       where K: Eq + Hash;
}

Required Associated Types§

Required Methods§

Source

fn each_count(self) -> HashMap<Self::Item, u64>
where Self::Item: Hash + Eq,

gives a count of each unique item that exist

Source

fn each_count_by<K>(self, selector: fn(_: Self::Item) -> K) -> HashMap<K, u64>
where K: Eq + Hash,

gives a count of each unique item decided by the selector This is essentially map + each_count

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<I, T> EachCount for I
where I: IntoIterator<Item = T>,

Source§

type Item = T