diff options
| author | Alexis Beingessner <a.beingessner@gmail.com> | 2014-09-18 17:05:52 -0400 |
|---|---|---|
| committer | Alexis Beingessner <a.beingessner@gmail.com> | 2014-09-24 21:53:58 -0400 |
| commit | fe8a413fc0f5d7d021ec42ac1a4149db662ca92c (patch) | |
| tree | 4b69db548f43514ff30815703f6ad413902efdb7 /src/librustdoc/html/render.rs | |
| parent | 8e58f3088b5c86339f8d2cdbdb37d1c54af08bca (diff) | |
| download | rust-fe8a413fc0f5d7d021ec42ac1a4149db662ca92c.tar.gz rust-fe8a413fc0f5d7d021ec42ac1a4149db662ca92c.zip | |
handling fallout from entry api
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); } |
