AsRef instead of Deref to prevent accidental quoting
diff --git a/src/common.rs b/src/common.rs
index 9c5de75..b2f498d 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -1,5 +1,4 @@
use std::fmt::{self, Display};
-use std::ops::Deref;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Ident(String);
@@ -22,10 +21,8 @@
}
}
-impl Deref for Ident {
- type Target = str;
-
- fn deref(&self) -> &str {
+impl AsRef<str> for Ident {
+ fn as_ref(&self) -> &str {
&self.0
}
}
@@ -64,3 +61,15 @@
)
));
}
+
+#[cfg(feature = "printing")]
+mod printing {
+ use super::*;
+ use quote::{Tokens, ToTokens};
+
+ impl ToTokens for Ident {
+ fn to_tokens(&self, tokens: &mut Tokens) {
+ tokens.append(self.as_ref())
+ }
+ }
+}