@@ -72,9 +72,9 @@ impl Decodable for Symbol {
72
72
}
73
73
}
74
74
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 ( )
78
78
}
79
79
}
80
80
@@ -244,11 +244,47 @@ fn with_interner<T, F: FnOnce(&mut Interner) -> T>(f: F) -> T {
244
244
/// destroyed. In particular, they must not access string contents. This can
245
245
/// be fixed in the future by just leaking all strings until thread death
246
246
/// somehow.
247
- #[ derive( Clone , PartialEq , Hash , PartialOrd , Eq , Ord ) ]
247
+ #[ derive( Clone , Hash , PartialOrd , Eq , Ord ) ]
248
248
pub struct InternedString {
249
249
string : & ' static str ,
250
250
}
251
251
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
+
252
288
impl !Send for InternedString { }
253
289
254
290
impl :: std:: ops:: Deref for InternedString {
0 commit comments