Add verbatim variants as an escape hatch
diff --git a/src/ty.rs b/src/ty.rs
index 7cc7843..e26c52e 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -1,5 +1,10 @@
use delimited::Delimited;
use super::*;
+use proc_macro2::TokenStream;
+#[cfg(feature = "extra-traits")]
+use std::hash::{Hash, Hasher};
+#[cfg(feature = "extra-traits")]
+use mac::TokenStreamHelper;
ast_enum_of_structs! {
/// The different kinds of types recognized by the compiler
@@ -87,6 +92,29 @@
}),
/// A macro in the type position.
pub Macro(Macro),
+ pub Verbatim(TypeVerbatim #manual_extra_traits {
+ pub tts: TokenStream,
+ }),
+ }
+}
+
+#[cfg(feature = "extra-traits")]
+impl Eq for TypeVerbatim {}
+
+#[cfg(feature = "extra-traits")]
+impl PartialEq for TypeVerbatim {
+ fn eq(&self, other: &Self) -> bool {
+ TokenStreamHelper(&self.tts) == TokenStreamHelper(&other.tts)
+ }
+}
+
+#[cfg(feature = "extra-traits")]
+impl Hash for TypeVerbatim {
+ fn hash<H>(&self, state: &mut H)
+ where
+ H: Hasher,
+ {
+ TokenStreamHelper(&self.tts).hash(state);
}
}
@@ -941,6 +969,12 @@
}
}
+ impl ToTokens for TypeVerbatim {
+ fn to_tokens(&self, tokens: &mut Tokens) {
+ self.tts.to_tokens(tokens);
+ }
+ }
+
impl ToTokens for Path {
fn to_tokens(&self, tokens: &mut Tokens) {
self.leading_colon.to_tokens(tokens);