@@ -68,43 +68,7 @@ extern crate proc_macro;
68
68
use proc_macro:: TokenStream ;
69
69
use proc_macro2:: Span ;
70
70
use quote:: quote;
71
- use std:: fmt;
72
- use syn:: { Data , Fields , Ident , Path } ;
73
-
74
- #[ derive( Copy , Clone ) ]
75
- struct Symbol ( & ' static str ) ;
76
-
77
- const NUM_TRAITS : Symbol = Symbol ( "num_traits" ) ;
78
-
79
- impl PartialEq < Symbol > for Ident {
80
- fn eq ( & self , word : & Symbol ) -> bool {
81
- self == word. 0
82
- }
83
- }
84
-
85
- impl < ' a > PartialEq < Symbol > for & ' a Ident {
86
- fn eq ( & self , word : & Symbol ) -> bool {
87
- * self == word. 0
88
- }
89
- }
90
-
91
- impl PartialEq < Symbol > for Path {
92
- fn eq ( & self , word : & Symbol ) -> bool {
93
- self . is_ident ( word. 0 )
94
- }
95
- }
96
-
97
- impl < ' a > PartialEq < Symbol > for & ' a Path {
98
- fn eq ( & self , word : & Symbol ) -> bool {
99
- self . is_ident ( word. 0 )
100
- }
101
- }
102
-
103
- impl fmt:: Display for Symbol {
104
- fn fmt ( & self , formatter : & mut fmt:: Formatter ) -> fmt:: Result {
105
- formatter. write_str ( self . 0 )
106
- }
107
- }
71
+ use syn:: { Data , Fields , Ident } ;
108
72
109
73
// Within `exp`, you can bring things into scope with `extern crate`.
110
74
//
@@ -179,15 +143,15 @@ fn newtype_inner(data: &syn::Data) -> Option<syn::Type> {
179
143
fn find_explicit_import_ident ( attrs : & [ syn:: Attribute ] ) -> Option < syn:: Ident > {
180
144
for attr in attrs {
181
145
if let Ok ( syn:: Meta :: NameValue ( mnv) ) = attr. parse_meta ( ) {
182
- if mnv. path == NUM_TRAITS {
146
+ if mnv. path . is_ident ( "num_traits" ) {
183
147
match mnv. lit {
184
148
syn:: Lit :: Str ( lit_str) => {
185
149
let import_str = & lit_str. value ( ) ;
186
150
let span = proc_macro2:: Span :: call_site ( ) ;
187
151
let import_ident = syn:: Ident :: new ( import_str, span) ;
188
152
return Some ( import_ident) ;
189
153
}
190
- _ => panic ! ( "#[{} ] attribute value must be a str" , NUM_TRAITS ) ,
154
+ _ => panic ! ( "#[num_traits ] attribute value must be a str" ) ,
191
155
}
192
156
}
193
157
}
0 commit comments