[breaking change] Update entry API as part of RFC 509.

This commit is contained in:
Ben Foppa
2015-01-04 14:07:32 -05:00
parent 260e46115b
commit 400c3a0ddc
20 changed files with 170 additions and 135 deletions

View File

@@ -36,7 +36,6 @@ pub use self::ExternalLocation::*;
use std::cell::RefCell;
use std::cmp::Ordering::{self, Less, Greater, Equal};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{HashMap, HashSet};
use std::default::Default;
use std::fmt;
@@ -822,10 +821,8 @@ impl DocFolder for Cache {
if let clean::ImplItem(ref i) = item.inner {
match i.trait_ {
Some(clean::ResolvedPath{ did, .. }) => {
let v = match self.implementors.entry(did) {
Vacant(entry) => entry.set(Vec::with_capacity(1)),
Occupied(entry) => entry.into_mut(),
};
let v = self.implementors.entry(&did).get().unwrap_or_else(
|vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
v.push(Implementor {
def_id: item.def_id,
generics: i.generics.clone(),
@@ -1014,10 +1011,8 @@ impl DocFolder for Cache {
};
if let Some(did) = did {
let v = match self.impls.entry(did) {
Vacant(entry) => entry.set(Vec::with_capacity(1)),
Occupied(entry) => entry.into_mut(),
};
let v = self.impls.entry(&did).get().unwrap_or_else(
|vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
v.push(Impl {
impl_: i,
dox: dox,
@@ -1264,10 +1259,9 @@ impl Context {
None => continue,
Some(ref s) => s.to_string(),
};
let v = match map.entry(short.to_string()) {
Vacant(entry) => entry.set(Vec::with_capacity(1)),
Occupied(entry) => entry.into_mut(),
};
let short = short.to_string();
let v = map.entry(&short).get().unwrap_or_else(
|vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
v.push(myname);
}