Into_values alternative or workaround

I've found myself wanting to use an into_ variant of HashMap.values() only to find this issue:

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 :slight_smile:


Option (what max returns), has an enormous number of small utility functions! There is almost one for any use-case


Ah ha! Thank you so much, I should have known to check what tools Option had to offer!

But I was distracted by the iterator methods :upside_down_face:

Now I recall the book's advice:

Becoming familiar with the methods on Option<T> will be extremely useful in your journey with Rust.