Frequency of an element in the vector

If you want to get all the frequencies in a single pass, you can store them in some sort of map, like a HashMap:

    let mut m: HashMap<i32, usize> = HashMap::new();
    for x in v {
        *m.entry(x).or_default() += 1;
    }

Then, iterate over the map to find the key with the highest value:

    let max = m.into_iter().max_by_key(|(_, v)| *v).map(|(k, _)| k);

(Playground)

If you don't like for loops, you can use fold instead, though I don't think this particularly makes it more "functional." It's just a different way of writing the same loop.

    let max = v.into_iter()
        .fold(HashMap::<i32, usize>::new(), |mut m, x| {
            *m.entry(x).or_default() += 1;
            m
        })
        .into_iter()
        .max_by_key(|(_, v)| *v)
        .map(|(k, _)| k);

(Playground)