fn first_char_sort_by_freq<F>(&self, mut cmp: F) -> Option<char>
            where F: FnMut(&u32, &u32) -> ::std::cmp::Ordering
        {
            // build a vector of tuple (char, frequency) from the hash (key, value) so we can sort
            // our results.
            let mut vec: Vec<_> = self.iter().collect();
            vec.sort_by(|&(_, freqa), &(_, freqb)| cmp(freqa, freqb));
            // map to the char, we don't need the frequency anymore
            vec.into_iter().map(|(&ch, _)| ch).next()
        }
/// Returns the first character of self sorted by a given `cmp` comparison function on the
/// frequency.
Returns the first character of self sorted by a given `cmp` comparison function on the
frequency.
Returns the first character of self sorted by a given ` cmp ` comparison function on the frequency .
fn first_char_sort_by_freq<F>(&self, mut cmp: F) -> Option<char>
            where F: FnMut(&u32, &u32) -> ::std::cmp::Ordering
        {
            // build a vector of tuple (char, frequency) from the hash (key, value) so we can sort
            // our results.
            let mut vec: Vec<_> = self.iter().collect();
            vec.sort_by(|&(_, freqa), &(_, freqb)| cmp(freqa, freqb));
            // map to the char, we don't need the frequency anymore
            vec.into_iter().map(|(&ch, _)| ch).next()
        }
fn first_char_sort_by_freq < F > ( & self , mut cmp : F ) -> Option < char > where F : FnMut ( & u32 , & u32 ) -> :: std :: cmp :: Ordering { // build a vector of tuple (char, frequency) from the hash (key, value) so we can sort // our results. let mut vec : Vec < _ > = self . iter ( ) . collect ( ) ; vec . sort_by ( | & ( _ , freqa ) , & ( _ , freqb ) | cmp ( freqa , freqb ) ) ; // map to the char, we don't need the frequency anymore vec . into_iter ( ) . map ( | ( & ch , _ ) | ch ) . next ( ) }
Returns the first character of self sorted by a given `cmp` comparison function on the
frequency.
Returns the first character of self sorted by a given ` cmp ` comparison function on the frequency .
&self
cmp
F
&self
cmp
F