improve speed of to_string for Classes
@@ -84,13 +84,11 @@ impl Classes {
impl ToString for Classes {
fn to_string(&self) -> String {
- let mut buf = String::new();
- for class in &self.set {
- buf.push_str(class);
- buf.push(' ');
- }
- buf.pop();
- buf
+ self.set
+ .iter()
+ .map(String::as_str)
+ .collect::<Vec<&str>>()
+ .join(" ")
}
}
