Simple object to count Rust iterables
Full Changelog: https://github.com/coriolinus/counter-rs/compare/v0.5.6...v0.5.7
k
most common items and speed up most_common_*()
methods by @clint-white in https://github.com/coriolinus/counter-rs/pull/25
Full Changelog: https://github.com/coriolinus/counter-rs/compare/v0.5.5...v0.5.6
Counter::total()
by @clint-white in https://github.com/coriolinus/counter-rs/pull/20
Full Changelog: https://github.com/coriolinus/counter-rs/compare/v0.5.4...v0.5.5
Default
implementation by @jonasbb in https://github.com/coriolinus/counter-rs/pull/19
Full Changelog: https://github.com/coriolinus/counter-rs/compare/v0.5.3...v0.5.4
Full Changelog: https://github.com/coriolinus/counter-rs/compare/v0.5.2...v0.5.3
Implementing these traits gives users more ways to usefully combine their counts.
This release removes self-cloning from the Add, Sub, and BitOr impls. This also fixes a number of other clippy, minor clippy lints.
Counters now implement Index
and IndexMut
, so they can have implicit zero counts. In other words:
# use counter::Counter;
let counter = "aaa".chars().collect::<Counter<_>>();
assert_eq!(counter[&'b'], 0);
// panics
// assert_eq!((*counter)[&'b'], 0);
This is a breaking change, causing a minor version bump, because it is not impossible that previous code depended on indexing panicing for unknown entries. Code which does not panic as part of its intended control flow will not be affected.
All Copy
types are also Clone
types where the clone bound happens to be really cheap. Bounding N: Clone
instead of N: Copy
means that we can use numeric types like num::BigInteger
, which are not Copy
, and things still work. You pay a bit more runtime cost, but if you're using a non-default counter type, presumably you know the costs of your actions.
N: Clone
mandatory bound