Skip to content

Commit d4cf5d8

Browse files
committed
remove Symbol, just compare is_ident directly
1 parent 824074f commit d4cf5d8

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

src/lib.rs

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,43 +68,7 @@ extern crate proc_macro;
6868
use proc_macro::TokenStream;
6969
use proc_macro2::Span;
7070
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};
10872

10973
// Within `exp`, you can bring things into scope with `extern crate`.
11074
//
@@ -179,15 +143,15 @@ fn newtype_inner(data: &syn::Data) -> Option<syn::Type> {
179143
fn find_explicit_import_ident(attrs: &[syn::Attribute]) -> Option<syn::Ident> {
180144
for attr in attrs {
181145
if let Ok(syn::Meta::NameValue(mnv)) = attr.parse_meta() {
182-
if mnv.path == NUM_TRAITS {
146+
if mnv.path.is_ident("num_traits") {
183147
match mnv.lit {
184148
syn::Lit::Str(lit_str) => {
185149
let import_str = &lit_str.value();
186150
let span = proc_macro2::Span::call_site();
187151
let import_ident = syn::Ident::new(import_str, span);
188152
return Some(import_ident);
189153
}
190-
_ => panic!("#[{}] attribute value must be a str", NUM_TRAITS),
154+
_ => panic!("#[num_traits] attribute value must be a str"),
191155
}
192156
}
193157
}

0 commit comments

Comments
 (0)