diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-04-26 16:27:10 +0200 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-04-26 16:27:10 +0200 |
| commit | 6343f261f4aeacdd292bf07998ef5faf6e90d57b (patch) | |
| tree | 086bb7c2a2b1af4d22df26d8085911935ed5555e /src/libsyntax/parse | |
| parent | cfae4dea875ddcc5f23481106a149ea15b6be1e5 (diff) | |
| download | rust-6343f261f4aeacdd292bf07998ef5faf6e90d57b.tar.gz rust-6343f261f4aeacdd292bf07998ef5faf6e90d57b.zip | |
allow InternedString to be compared to &str directly
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/token.rs | 22 |
1 files changed, 22 insertions, 0 deletions
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<InternedString> for &'a str { } } +impl PartialEq<str> 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<InternedString> 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: Decoder>(d: &mut D) -> Result<InternedString, D::Error> { Ok(intern(d.read_str()?.as_ref()).as_str()) |
