File tree Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Expand file tree Collapse file tree 3 files changed +45
-2
lines changed Original file line number Diff line number Diff line change @@ -822,7 +822,7 @@ impl Ident {
822822
823823impl PartialEq for Ident {
824824 fn eq ( & self , other : & Ident ) -> bool {
825- self . to_string ( ) == other. to_string ( )
825+ self . inner == other. inner
826826 }
827827}
828828
@@ -831,7 +831,7 @@ where
831831 T : ?Sized + AsRef < str > ,
832832{
833833 fn eq ( & self , other : & T ) -> bool {
834- self . to_string ( ) == other. as_ref ( )
834+ self . inner == other
835835 }
836836}
837837
Original file line number Diff line number Diff line change @@ -500,6 +500,26 @@ fn validate_term(string: &str) {
500500 }
501501}
502502
503+ impl PartialEq for Ident {
504+ fn eq ( & self , other : & Ident ) -> bool {
505+ self . sym == other. sym && self . raw == other. raw
506+ }
507+ }
508+
509+ impl < T > PartialEq < T > for Ident
510+ where
511+ T : ?Sized + AsRef < str > ,
512+ {
513+ fn eq ( & self , other : & T ) -> bool {
514+ let other = other. as_ref ( ) ;
515+ if self . raw {
516+ other. starts_with ( "r#" ) && self . sym == other[ 2 ..]
517+ } else {
518+ self . sym == other
519+ }
520+ }
521+ }
522+
503523impl fmt:: Display for Ident {
504524 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
505525 if self . raw {
Original file line number Diff line number Diff line change @@ -573,6 +573,29 @@ impl Ident {
573573 }
574574}
575575
576+ impl PartialEq for Ident {
577+ fn eq ( & self , other : & Ident ) -> bool {
578+ match ( self , other) {
579+ ( Ident :: Nightly ( t) , Ident :: Nightly ( o) ) => t. to_string ( ) == o. to_string ( ) ,
580+ ( Ident :: Stable ( t) , Ident :: Stable ( o) ) => t == o,
581+ _ => mismatch ( ) ,
582+ }
583+ }
584+ }
585+
586+ impl < T > PartialEq < T > for Ident
587+ where
588+ T : ?Sized + AsRef < str > ,
589+ {
590+ fn eq ( & self , other : & T ) -> bool {
591+ let other = other. as_ref ( ) ;
592+ match self {
593+ Ident :: Nightly ( t) => t. to_string ( ) == other,
594+ Ident :: Stable ( t) => t == other,
595+ }
596+ }
597+ }
598+
576599impl fmt:: Display for Ident {
577600 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
578601 match self {
You can’t perform that action at this time.
0 commit comments