I've found myself wanting to use an into_
variant of HashMap.values() only to find this issue:
https://github.com/rust-lang/rust/issues/55214
What would you recommend as a workaround?
I found the following "pattern match solution" when writing a mode function - working on the summary exercises for chapter 8 of the book:
But I wonder if this section (snipped):
fn mode(...) -> Option<i32> {
....
match counts.values().max() {
Some(&x) => Some(x),
None => None,
}
}
is sensible, it seems verbose to me (even for rust). I want to return Option and not the Option<&i32> max returns. It feels like I'm missing a helpful function. If not into_values
, then what, if anything?
I also wonder if I'm missing some of the nuances of iterators and chaining .values() and .max(), perhaps?
Any help or advice would be appreciated, is there a better way? Thanks for reading