diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-10-24 12:25:50 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-10-31 07:25:34 -0500 |
| commit | 1384a43db3a8b1551bfc3c6feb37e2174d4c2ba0 (patch) | |
| tree | e45a0343003c22ed5b1ccbaa008189db578c3658 /src/libsyntax/util | |
| parent | 065caf34f5ff29e04605f95d9c5d511af219439a (diff) | |
| download | rust-1384a43db3a8b1551bfc3c6feb37e2174d4c2ba0.tar.gz rust-1384a43db3a8b1551bfc3c6feb37e2174d4c2ba0.zip | |
DSTify Hash
- The signature of the `*_equiv` methods of `HashMap` and similar structures
have changed, and now require one less level of indirection. Change your code
from:
```
hashmap.find_equiv(&"Hello");
hashmap.find_equiv(&&[0u8, 1, 2]);
```
to:
```
hashmap.find_equiv("Hello");
hashmap.find_equiv(&[0u8, 1, 2]);
```
- The generic parameter `T` of the `Hasher::hash<T>` method have become
`Sized?`. Downstream code must add `Sized?` to that method in their
implementations. For example:
```
impl Hasher<FnvState> for FnvHasher {
fn hash<T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
}
```
must be changed to:
```
impl Hasher<FnvState> for FnvHasher {
fn hash<Sized? T: Hash<FnvState>>(&self, t: &T) -> u64 { /* .. */ }
// ^^^^^^
}
```
[breaking-change]
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index ed2455d0a30..105118ff76a 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -75,7 +75,7 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> { (*vect).len() } - pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> { + pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> { let map = self.map.borrow(); match (*map).find_equiv(val) { Some(v) => Some(*v), @@ -149,7 +149,7 @@ impl StrInterner { pub fn intern(&self, val: &str) -> Name { let mut map = self.map.borrow_mut(); - match map.find_equiv(&val) { + match map.find_equiv(val) { Some(&idx) => return idx, None => (), } @@ -195,7 +195,7 @@ impl StrInterner { self.vect.borrow().len() } - pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> { + pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> { match (*self.map.borrow()).find_equiv(val) { Some(v) => Some(*v), None => None, |
