From e0684e876954ad5a713e6f985570162cedcae8df Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 6 Jan 2015 10:16:49 +1300 Subject: Fallout --- src/libstd/collections/hash/map.rs | 34 +++++++++++++++++----------------- src/libstd/collections/hash/set.rs | 4 ++-- src/libstd/collections/hash/table.rs | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/libstd/collections') diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index a6532707f3e..300fc849ace 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -440,14 +440,14 @@ impl SearchResult { } impl, V, S, H: Hasher> HashMap { - fn make_hash>(&self, x: &X) -> SafeHash { + fn make_hash>(&self, x: &X) -> SafeHash { table::make_hash(&self.hasher, x) } /// Search for a key, yielding the index if it's found in the hashtable. /// If you already have the hash for the key lying around, use /// search_hashed. - fn search<'a, Sized? Q>(&'a self, q: &Q) -> Option> + fn search<'a, Q: ?Sized>(&'a self, q: &Q) -> Option> where Q: BorrowFrom + Eq + Hash { let hash = self.make_hash(q); @@ -455,7 +455,7 @@ impl, V, S, H: Hasher> HashMap { .into_option() } - fn search_mut<'a, Sized? Q>(&'a mut self, q: &Q) -> Option> + fn search_mut<'a, Q: ?Sized>(&'a mut self, q: &Q) -> Option> where Q: BorrowFrom + Eq + Hash { let hash = self.make_hash(q); @@ -923,7 +923,7 @@ impl, V, S, H: Hasher> HashMap { #[stable] /// Gets the given key's corresponding entry in the map for in-place manipulation. /// Regardless of whether or not `to_owned()` has been called, the key must hash the same way. - pub fn entry<'a, Sized? Q>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V> + pub fn entry<'a, Q: ?Sized>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V> where Q: Eq + Hash + ToOwned { // Gotta resize now. @@ -1030,7 +1030,7 @@ impl, V, S, H: Hasher> HashMap { /// assert_eq!(map.get(&2), None); /// ``` #[stable] - pub fn get(&self, k: &Q) -> Option<&V> + pub fn get(&self, k: &Q) -> Option<&V> where Q: Hash + Eq + BorrowFrom { self.search(k).map(|bucket| bucket.into_refs().1) @@ -1053,7 +1053,7 @@ impl, V, S, H: Hasher> HashMap { /// assert_eq!(map.contains_key(&2), false); /// ``` #[stable] - pub fn contains_key(&self, k: &Q) -> bool + pub fn contains_key(&self, k: &Q) -> bool where Q: Hash + Eq + BorrowFrom { self.search(k).is_some() @@ -1079,7 +1079,7 @@ impl, V, S, H: Hasher> HashMap { /// assert_eq!(map[1], "b"); /// ``` #[stable] - pub fn get_mut(&mut self, k: &Q) -> Option<&mut V> + pub fn get_mut(&mut self, k: &Q) -> Option<&mut V> where Q: Hash + Eq + BorrowFrom { self.search_mut(k).map(|bucket| bucket.into_mut_refs().1) @@ -1131,7 +1131,7 @@ impl, V, S, H: Hasher> HashMap { /// assert_eq!(map.remove(&1), None); /// ``` #[stable] - pub fn remove(&mut self, k: &Q) -> Option + pub fn remove(&mut self, k: &Q) -> Option where Q: Hash + Eq + BorrowFrom { if self.table.size() == 0 { @@ -1142,7 +1142,7 @@ impl, V, S, H: Hasher> HashMap { } } -fn search_entry_hashed<'a, K, V, Sized? Q>(table: &'a mut RawTable, hash: SafeHash, k: &'a Q) +fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable, hash: SafeHash, k: &'a Q) -> Entry<'a, Q, K, V> where Q: Eq + ToOwned { @@ -1229,7 +1229,7 @@ impl, V, S, H: Hasher + Default> Default for HashMap // NOTE(stage0): remove impl after a snapshot #[cfg(stage0)] #[stable] -impl + Eq, Sized? Q, V, S, H: Hasher> Index for HashMap +impl + Eq, Q: ?Sized, V, S, H: Hasher> Index for HashMap where Q: BorrowFrom + Hash + Eq { #[inline] @@ -1240,7 +1240,7 @@ impl + Eq, Sized? Q, V, S, H: Hasher> Index for HashMap + Eq, Sized? Q, V, S, H: Hasher> Index for HashMap +impl + Eq, Q: ?Sized, V, S, H: Hasher> Index for HashMap where Q: BorrowFrom + Hash + Eq { type Output = V; @@ -1254,7 +1254,7 @@ impl + Eq, Sized? Q, V, S, H: Hasher> Index for HashMap + Eq, Sized? Q, V, S, H: Hasher> IndexMut for HashMap +impl + Eq, Q: ?Sized, V, S, H: Hasher> IndexMut for HashMap where Q: BorrowFrom + Hash + Eq { #[inline] @@ -1265,7 +1265,7 @@ impl + Eq, Sized? Q, V, S, H: Hasher> IndexMut for HashMap + Eq, Sized? Q, V, S, H: Hasher> IndexMut for HashMap +impl + Eq, Q: ?Sized, V, S, H: Hasher> IndexMut for HashMap where Q: BorrowFrom + Hash + Eq { type Output = V; @@ -1357,7 +1357,7 @@ pub struct OccupiedEntry<'a, K: 'a, V: 'a> { #[stable] /// A view into a single empty location in a HashMap -pub struct VacantEntry<'a, Sized? Q: 'a, K: 'a, V: 'a> { +pub struct VacantEntry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> { hash: SafeHash, key: &'a Q, elem: VacantEntryState>, @@ -1365,7 +1365,7 @@ pub struct VacantEntry<'a, Sized? Q: 'a, K: 'a, V: 'a> { #[stable] /// A view into a single location in a map, which may be vacant or occupied -pub enum Entry<'a, Sized? Q: 'a, K: 'a, V: 'a> { +pub enum Entry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> { /// An occupied Entry Occupied(OccupiedEntry<'a, K, V>), /// A vacant Entry @@ -1435,7 +1435,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Drain<'a, K, V> { } } -impl<'a, Sized? Q, K, V> Entry<'a, Q, K, V> { +impl<'a, Q: ?Sized, K, V> Entry<'a, Q, K, V> { #[unstable = "matches collection reform v2 specification, waiting for dust to settle"] /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> { @@ -1481,7 +1481,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> { } } -impl<'a, Sized? Q: 'a + ToOwned, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> { +impl<'a, Q: ?Sized + 'a + ToOwned, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> { #[stable] /// Sets the value of the entry with the VacantEntry's key, /// and returns a mutable reference to it diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index b1824db93aa..f77eaa237c1 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -451,7 +451,7 @@ impl, S, H: Hasher> HashSet { /// assert_eq!(set.contains(&4), false); /// ``` #[stable] - pub fn contains(&self, value: &Q) -> bool + pub fn contains(&self, value: &Q) -> bool where Q: BorrowFrom + Hash + Eq { self.map.contains_key(value) @@ -561,7 +561,7 @@ impl, S, H: Hasher> HashSet { /// assert_eq!(set.remove(&2), false); /// ``` #[stable] - pub fn remove(&mut self, value: &Q) -> bool + pub fn remove(&mut self, value: &Q) -> bool where Q: BorrowFrom + Hash + Eq { self.map.remove(value).is_some() diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index ab91beb4f9b..1eb4408eedc 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -138,7 +138,7 @@ impl SafeHash { /// We need to remove hashes of 0. That's reserved for empty buckets. /// This function wraps up `hash_keyed` to be the only way outside this /// module to generate a SafeHash. -pub fn make_hash, S, H: Hasher>(hasher: &H, t: &T) -> SafeHash { +pub fn make_hash, S, H: Hasher>(hasher: &H, t: &T) -> SafeHash { // We need to avoid 0u64 in order to prevent collisions with // EMPTY_HASH. We can maintain our precious uniform distribution // of initial indexes by unconditionally setting the MSB, -- cgit 1.4.1-3-g733a5