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 {
822
822
823
823
impl PartialEq for Ident {
824
824
fn eq ( & self , other : & Ident ) -> bool {
825
- self . to_string ( ) == other. to_string ( )
825
+ self . inner == other. inner
826
826
}
827
827
}
828
828
@@ -831,7 +831,7 @@ where
831
831
T : ?Sized + AsRef < str > ,
832
832
{
833
833
fn eq ( & self , other : & T ) -> bool {
834
- self . to_string ( ) == other. as_ref ( )
834
+ self . inner == other
835
835
}
836
836
}
837
837
Original file line number Diff line number Diff line change @@ -500,6 +500,26 @@ fn validate_term(string: &str) {
500
500
}
501
501
}
502
502
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
+
503
523
impl fmt:: Display for Ident {
504
524
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
505
525
if self . raw {
Original file line number Diff line number Diff line change @@ -573,6 +573,29 @@ impl Ident {
573
573
}
574
574
}
575
575
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
+
576
599
impl fmt:: Display for Ident {
577
600
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
578
601
match self {
You can’t perform that action at this time.
0 commit comments