diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-11-21 00:14:05 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-03 10:41:42 -0500 |
| commit | 2840d58dab0144c5589b60322c4f681bd8052aba (patch) | |
| tree | 0c48a16b8c12222544acc8f2e7289381bd5af631 /src/libsyntax/parse | |
| parent | 2578de9d6090210d9e94fd013190f387c8a88048 (diff) | |
| download | rust-2840d58dab0144c5589b60322c4f681bd8052aba.tar.gz rust-2840d58dab0144c5589b60322c4f681bd8052aba.zip | |
Overload the `==` operator
- String == &str == CowString - Vec == &[T] == &mut [T] == [T, ..N] == CowVec - InternedString == &str
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 37df2bf14c2..1376f59d79f 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -629,6 +629,28 @@ impl<'a> Equiv<&'a str> for InternedString { } } +impl<'a> PartialEq<&'a str> for InternedString { + #[inline(always)] + fn eq(&self, other: & &'a str) -> bool { + PartialEq::eq(self.string.as_slice(), *other) + } + #[inline(always)] + fn ne(&self, other: & &'a str) -> bool { + PartialEq::ne(self.string.as_slice(), *other) + } +} + +impl<'a> PartialEq<InternedString > for &'a str { + #[inline(always)] + fn eq(&self, other: &InternedString) -> bool { + PartialEq::eq(*self, other.string.as_slice()) + } + #[inline(always)] + fn ne(&self, other: &InternedString) -> bool { + PartialEq::ne(*self, other.string.as_slice()) + } +} + impl<D:Decoder<E>, E> Decodable<D, E> for InternedString { fn decode(d: &mut D) -> Result<InternedString, E> { Ok(get_name(get_ident_interner().intern( |
