Imagine a vector of structs like the following:
struct User {
active: bool,
premium: bool,
username: String,
email: String,
logins: u64,
group_id: u64,
site_id: u64,
}
I'm currently iterating over the vector and then creating small buckets of my counts using hashmaps. This allows me to know how count users grouping by group_id or site_id, max logins of a user per site, etc. So far, everything works and I'm happy with the code.
However, I was wondering if there is a smarter and faster way of doing this? Do people use libraries for this kind of thing? Or am I doing the right way?
ps.: My use case is stream analysis. Basically my rust code is listening on a queue and as events come through, I collect them and save into a vector. Once I judge that vector to be large enough, I do my aggregations and save into a table.