@@ -72,9 +72,9 @@ impl Decodable for Symbol {
7272 }
7373}
7474
75- impl < ' a > PartialEq < & ' a str > for Symbol {
76- fn eq ( & self , other : & & str ) -> bool {
77- * self . as_str ( ) == * * other
75+ impl < T : :: std :: ops :: Deref < Target = str > > PartialEq < T > for Symbol {
76+ fn eq ( & self , other : & T ) -> bool {
77+ self . as_str ( ) == other. deref ( )
7878 }
7979}
8080
@@ -244,11 +244,47 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
244244/// destroyed. In particular, they must not access string contents. This can
245245/// be fixed in the future by just leaking all strings until thread death
246246/// somehow.
247- #[ derive( Clone , PartialEq , Hash , PartialOrd , Eq , Ord ) ]
247+ #[ derive( Clone , Hash , PartialOrd , Eq , Ord ) ]
248248pub struct InternedString {
249249 string : & ' static str ,
250250}
251251
252+ impl < U : ?Sized > :: std:: convert:: AsRef < U > for InternedString where str : :: std:: convert:: AsRef < U > {
253+ fn as_ref ( & self ) -> & U {
254+ self . string . as_ref ( )
255+ }
256+ }
257+
258+ impl < T : :: std:: ops:: Deref < Target = str > > :: std:: cmp:: PartialEq < T > for InternedString {
259+ fn eq ( & self , other : & T ) -> bool {
260+ self . string == other. deref ( )
261+ }
262+ }
263+
264+ impl :: std:: cmp:: PartialEq < InternedString > for str {
265+ fn eq ( & self , other : & InternedString ) -> bool {
266+ self == other. string
267+ }
268+ }
269+
270+ impl < ' a > :: std:: cmp:: PartialEq < InternedString > for & ' a str {
271+ fn eq ( & self , other : & InternedString ) -> bool {
272+ * self == other. string
273+ }
274+ }
275+
276+ impl :: std:: cmp:: PartialEq < InternedString > for String {
277+ fn eq ( & self , other : & InternedString ) -> bool {
278+ self == other. string
279+ }
280+ }
281+
282+ impl < ' a > :: std:: cmp:: PartialEq < InternedString > for & ' a String {
283+ fn eq ( & self , other : & InternedString ) -> bool {
284+ * self == other. string
285+ }
286+ }
287+
252288impl !Send for InternedString { }
253289
254290impl :: std:: ops:: Deref for InternedString {
0 commit comments