Skip to content

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

library/proc_macro/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,13 @@ impl fmt::Debug for Punct {
842842
}
843843
}
844844

845+
#[stable(feature = "proc_macro_punct_eq", since = "1.49.0")]
846+
impl PartialEq<char> for Punct {
847+
fn eq(&self, rhs: &char) -> bool {
848+
self.as_char() == *rhs
849+
}
850+
}
851+
845852
/// An identifier (`ident`).
846853
#[derive(Clone)]
847854
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]

library/proc_macro/tests/test.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(proc_macro_span)]
22

3-
use proc_macro::LineColumn;
3+
use proc_macro::{LineColumn, Punct};
44

55
#[test]
66
fn test_line_column_ord() {
@@ -10,3 +10,11 @@ fn test_line_column_ord() {
1010
assert!(line0_column0 < line0_column1);
1111
assert!(line0_column1 < line1_column0);
1212
}
13+
14+
#[test]
15+
fn test_punct_eq() {
16+
// Good enough if it typechecks, since proc_macro::Punct can't exist in a test.
17+
fn _check(punct: Punct) {
18+
let _ = punct == ':';
19+
}
20+
}

0 commit comments

Comments
 (0)