diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-11-12 15:51:51 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-11-17 11:26:48 -0800 |
| commit | 7213de1c49e448c7c6ad2d30dc3e6b3a13e090df (patch) | |
| tree | 9133e9f7b6f954432eddd947cb74248a1751ea36 /src/libsyntax/util | |
| parent | 80a2867ea736007397aa2fbaa0e4c539c80e162c (diff) | |
Fallout from deprecation
This commit handles the fallout from deprecating `_with` and `_equiv` methods.
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 08ada3e4435..ede967bba25 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -14,9 +14,9 @@ use ast::Name; +use std::borrow::BorrowFrom; use std::collections::HashMap; use std::cell::RefCell; -use std::cmp::Equiv; use std::fmt; use std::hash::Hash; use std::rc::Rc; @@ -75,9 +75,10 @@ impl<T: Eq + Hash + Clone + 'static> Interner<T> { (*vect).len() } - pub fn find_equiv<Sized? Q: Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> { + pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name> + where Q: BorrowFrom<T> + Eq + Hash { let map = self.map.borrow(); - match (*map).find_equiv(val) { + match (*map).get(val) { Some(v) => Some(*v), None => None, } @@ -117,6 +118,12 @@ impl fmt::Show for RcStr { } } +impl BorrowFrom<RcStr> for str { + fn borrow_from(owned: &RcStr) -> &str { + owned.string.as_slice() + } +} + impl RcStr { pub fn new(string: &str) -> RcStr { RcStr { @@ -149,7 +156,7 @@ impl StrInterner { pub fn intern(&self, val: &str) -> Name { let mut map = self.map.borrow_mut(); - match map.find_equiv(val) { + match map.get(val) { Some(&idx) => return idx, None => (), } @@ -195,8 +202,9 @@ impl StrInterner { self.vect.borrow().len() } - pub fn find_equiv<Sized? Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> { - match (*self.map.borrow()).find_equiv(val) { + pub fn find<Sized? Q>(&self, val: &Q) -> Option<Name> + where Q: BorrowFrom<RcStr> + Eq + Hash { + match (*self.map.borrow()).get(val) { Some(v) => Some(*v), None => None, } |
