diff options
Diffstat (limited to 'src/librustdoc/html/render.rs')
| -rw-r--r-- | src/librustdoc/html/render.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 2107854c52b..b9de64bb900 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -34,6 +34,7 @@ //! both occur before the crate is rendered. use std::collections::{HashMap, HashSet}; +use std::collections::hashmap::{Occupied, Vacant}; use std::fmt; use std::io::fs::PathExtensions; use std::io::{fs, File, BufferedWriter, MemWriter, BufferedReader}; @@ -801,9 +802,10 @@ impl DocFolder for Cache { clean::ImplItem(ref i) => { match i.trait_ { Some(clean::ResolvedPath{ did, .. }) => { - let v = self.implementors.find_or_insert_with(did, |_| { - Vec::new() - }); + let v = match self.implementors.entry(did) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(Implementor { def_id: item.def_id, generics: i.generics.clone(), @@ -998,9 +1000,10 @@ impl DocFolder for Cache { match did { Some(did) => { - let v = self.impls.find_or_insert_with(did, |_| { - Vec::new() - }); + let v = match self.impls.entry(did) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(Impl { impl_: i, dox: dox, @@ -2141,7 +2144,10 @@ fn build_sidebar(m: &clean::Module) -> HashMap<String, Vec<String>> { None => continue, Some(ref s) => s.to_string(), }; - let v = map.find_or_insert_with(short.to_string(), |_| Vec::new()); + let v = match map.entry(short.to_string()) { + Vacant(entry) => entry.set(Vec::with_capacity(1)), + Occupied(entry) => entry.into_mut(), + }; v.push(myname); } |
