Calculate mean, median, and mode from list of integers
There's no main method and more importantly, there are no tests. How do you know if the code works?
It's probably an artifact of learning a new language, but the code is overly documented. There's no reason to have comments describing what the implementation of the code is. It's more important to describe why a given implementation was chosen.
I would break out smaller functions to have somewhere for names to hang off of.
Documentation aspects:


"returns a ..." in docs is not useful; the return type already says that.
It is good to say why an error can occur though. You can also create a named error type that might have a variant like Error::EmptySlice, which is more self-describing.
"structure to ..." is docs is not useful; it is a struct.
"represent" is all programs do, so is redundant.
Avoid referring to concrete implementation details ("... is a Vec ...")

You have a good use of fold, but sum exists.
Median is the mode of the middle of the sorted vector. Now that there are functions, you can reuse them.
Why convert to a floating point, divide, then back to a usize? (sorted.len() as f64 / 2.0) as usize)
Don't declare the type of mode; let the compiler's type inference handle it.
Use Iterator::filter instead of the if in the loop.
Use Iterator::map instead of the manual destructuring in the for loop for (key, value).
Use Iterator::collect to create the Vec instead of creating it and pushing to a Vec.
I'd oneline the counting with the HashMap.
Use Iterator::max and unwrap_or to find the biggest value instead of doing it by hand.
You could track the maximum value during the first loop. This would save one iteration, but it's not as pretty.
The casts to f64 wen creating the structure are redundant; the values are already f64.




use std::collections::HashMap;

/// The mean, median, and mode of some integers.
#[derive(Debug)]
pub struct Calculations {
    mean: f64,
    median: f64,
    mode: Vec&lt;i32&gt;,
}

fn mean(values: &amp;[i32]) -&gt; f64 {
    let sum: i32 = values.iter().sum();
    sum as f64 / values.len() as f64
}

/// Returns the middle element of the elements in sorted order (or the
/// average of the middle 2 elements)
fn median(values: &amp;[i32]) -&gt; f64 {
    let mut sorted = values.to_vec();
    sorted.sort();

    let mid = sorted.len() / 2;

    if sorted.len() % 2 == 0 {
        mean(&amp;sorted[(mid - 1)..(mid + 1)])
    } else {
        sorted[mid] as f64
    }
}

fn mode(values: &amp;[i32]) -&gt; Vec&lt;i32&gt; {
    let mut occurrences = HashMap::new();

    for i in values {
        *occurrences.entry(i).or_insert(0) += 1;
    }

    let max_value = occurrences.values().cloned().max().unwrap_or(0);

    occurrences.into_iter()
        .filter(|&amp;(_, v)| v == max_value)
        .map(|(&amp;k, _)| k)
        .collect()
}

/// Calculates the mean, median, and mode of values.
/// It is an error to pass an empty slice
pub fn calculate_mmm(values: &amp;[i32]) -&gt; Result&lt;Calculations, &amp;str&gt; {
    if values.is_empty() {
        Err("Found empty slice")
    } else {
        Ok(Calculations {
            mean: mean(values),
            median: median(values),
            mode: mode(values),
        })
    }
}

fn main() {
    println!("{:?}", calculate_mmm(&amp;[3, 2, 1, 2]));
    println!("{:?}", calculate_mmm(&amp;[3, 2, 1]));
}