diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-10 19:46:38 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-21 23:31:42 -0800 |
| commit | 082bfde412176249dc7328e771a2a15d202824cf (patch) | |
| tree | 4df3816d6ffea2f52bf5fa51fe385806ed529ba7 /src/libsyntax/util | |
| parent | 4908017d59da8694b9ceaf743baf1163c1e19086 (diff) | |
| download | rust-082bfde412176249dc7328e771a2a15d202824cf.tar.gz rust-082bfde412176249dc7328e771a2a15d202824cf.zip | |
Fallout of std::str stabilization
Diffstat (limited to 'src/libsyntax/util')
| -rw-r--r-- | src/libsyntax/util/interner.rs | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 590a04ce221..97eb4316583 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -95,41 +95,37 @@ pub struct RcStr { string: Rc<String>, } +impl RcStr { + pub fn new(string: &str) -> RcStr { + RcStr { + string: Rc::new(string.to_string()), + } + } +} + impl Eq for RcStr {} impl Ord for RcStr { fn cmp(&self, other: &RcStr) -> Ordering { - self.as_slice().cmp(other.as_slice()) - } -} - -impl Str for RcStr { - #[inline] - fn as_slice<'a>(&'a self) -> &'a str { - let s: &'a str = self.string.as_slice(); - s + self[].cmp(other[]) } } impl fmt::Show for RcStr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { use std::fmt::Show; - self.as_slice().fmt(f) + self[].fmt(f) } } impl BorrowFrom<RcStr> for str { fn borrow_from(owned: &RcStr) -> &str { - owned.string.as_slice() + owned.string[] } } -impl RcStr { - pub fn new(string: &str) -> RcStr { - RcStr { - string: Rc::new(string.into_string()), - } - } +impl Deref<str> for RcStr { + fn deref(&self) -> &str { self.string[] } } /// A StrInterner differs from Interner<String> in that it accepts |
