From 6343f261f4aeacdd292bf07998ef5faf6e90d57b Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 26 Apr 2016 16:27:10 +0200 Subject: allow InternedString to be compared to &str directly --- src/libsyntax/parse/token.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index fcb6c3539db..47de32ed7d0 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -566,6 +566,28 @@ impl<'a> PartialEq for &'a str { } } +impl PartialEq for InternedString { + #[inline(always)] + fn eq(&self, other: &str) -> bool { + PartialEq::eq(&self.string[..], other) + } + #[inline(always)] + fn ne(&self, other: &str) -> bool { + PartialEq::ne(&self.string[..], other) + } +} + +impl PartialEq for str { + #[inline(always)] + fn eq(&self, other: &InternedString) -> bool { + PartialEq::eq(self, &other.string[..]) + } + #[inline(always)] + fn ne(&self, other: &InternedString) -> bool { + PartialEq::ne(self, &other.string[..]) + } +} + impl Decodable for InternedString { fn decode(d: &mut D) -> Result { Ok(intern(d.read_str()?.as_ref()).as_str()) -- cgit 1.4.1-3-g733a5