#counter #collection #module #python-counter #fpy

no-std counter-fpy

An implementation of Python's Counter module in Rust

2 releases

0.1.2 Dec 26, 2023
0.1.0 Dec 10, 2023

#132 in No standard library

38 downloads per month

MIT license

7KB
102 lines

Counter-fpy

An implementation of Python's Counter module in Rust.

https://docs.python.org/3/library/collections.html?highlight=counter#collections.Counter

Example


use counter_fpy::Counter;

fn main() {
    let sample = ["bxffour", "bxffour", "blackprince"];

    let counter = Counter::new();
    let collection = Counter::from(counter, &sample);

    for (key, count) in collection.iter() {
        println!("Key: {key} has count: {count}");
    }
}

No runtime deps