use std::collections::HashMap;

pub struct School {
    grades: HashMap<u32, Vec<String>>
}

impl School {
    pub fn new() -> School {
        School { grades: HashMap::new() }
    }

    pub fn add(&mut self, grade: u32, student: &str) {
        let mut entry = self.grades.entry(grade).or_insert(Vec::new());
        entry.push(student.to_string());
        entry.sort();
    }
    
    pub fn grades(&self) -> Vec<u32> {
        let mut s = self.grades.keys().cloned().collect::<Vec<u32>>();
        s.sort();
        s
    }

    pub fn grade(&self, grade: u32) -> Option<&Vec<String>> {
        self.grades.get(&grade)
    }
}

use std::collections::HashMap;

pub struct School {
    grades: HashMap<u32, Vec<String>>
}

impl School {
    pub fn new() -> School {
        School { grades: HashMap::new() }
    }

    pub fn add(&mut self, grade: u32, student: &str) {
        let mut entry = self.grades.entry(grade).or_insert(Vec::new());
        entry.push(student.to_string());
        entry.sort();
    }
    
    pub fn grades(&self) -> Vec<u32> {
        let mut s = self.grades.keys().map(|k| k.clone()).collect::<Vec<u32>>();
        s.sort();
        s
    }

    pub fn grade(&self, grade: u32) -> Option<&Vec<String>> {
        self.grades.get(&grade)
    }
}

--- 
+++ 
@@ -16,7 +16,7 @@
     }
     
     pub fn grades(&self) -> Vec<u32> {
-        let mut s = self.grades.keys().map(|k| k.clone()).collect::<Vec<u32>>();
+        let mut s = self.grades.keys().cloned().collect::<Vec<u32>>();
         s.sort();
         s
     }
grade-school: Use `cloned` instead of `map(|k| k.clone())`

They're equivalent, but I figure if there's already a function that does
the clone, might as well use it instead of `map` and making someone read
the body of the map.
