diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-04-28 09:51:44 -0400 |
|---|---|---|
| committer | Steve Klabnik <steve@steveklabnik.com> | 2016-04-28 09:51:44 -0400 |
| commit | 68f7fc52fdeffdec18d161ba995427d0cce53503 (patch) | |
| tree | 6853ed3af7705a3eaeca7bf2e6fe1df80918402b /src/libsyntax/parse | |
| parent | 7c2a98570c7458d612c9fd1e7f2e9817b6d28f01 (diff) | |
| parent | 6343f261f4aeacdd292bf07998ef5faf6e90d57b (diff) | |
| download | rust-68f7fc52fdeffdec18d161ba995427d0cce53503.tar.gz rust-68f7fc52fdeffdec18d161ba995427d0cce53503.zip | |
Rollup merge of #33218 - oli-obk:interned_str_cmp, r=nikomatsakis
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()) |
