1
Fork 0

Auto merge of #78636 - dtolnay:puncteq, r=petrochenkov

Add PartialEq<char> for proc_macro::Punct

`punct.as_char() == '░'` is pervasive when parsing anything involving punct. I think `punct == '░'` is sufficiently unambiguous that it makes sense to provide the impl.

1899c489d4/library/proc_macro/src/quote.rs (L79)
1899c489d4/library/proc_macro/src/quote.rs (L83)
1899c489d4/src/test/ui/suggestions/auxiliary/issue-61963.rs (L26)
1899c489d4/src/test/ui/proc-macro/auxiliary/three-equals.rs (L23)
This commit is contained in:
bors 2020-11-24 00:30:25 +00:00
commit cb5b87133a
2 changed files with 16 additions and 1 deletions

View file

@ -842,6 +842,13 @@ impl fmt::Debug for Punct {
}
}
#[stable(feature = "proc_macro_punct_eq", since = "1.49.0")]
impl PartialEq<char> for Punct {
fn eq(&self, rhs: &char) -> bool {
self.as_char() == *rhs
}
}
/// An identifier (`ident`).
#[derive(Clone)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]