aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-19 09:33:02 +0100
committerMartin Fischer <martin@push-f.com>2021-11-19 09:34:04 +0100
commit8e99d7bd6ebf9d1981667799f43cf45f682e1fff (patch)
tree57e67362c7a8aa87581555b2dfce2c87a1492843 /src/lib.rs
parent2a8a0601afcb82d90d0766db5a954b70b10f856d (diff)
refactor: factor out transform module
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1f0432c..7f4e040 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,9 +1,7 @@
#![doc = include_str!("../README.md")]
-use std::collections::HashMap;
use proc_macro::TokenStream;
use proc_macro2::Group;
-use proc_macro2::Ident;
use quote::format_ident;
use quote::quote;
use quote::quote_spanned;
@@ -42,9 +40,12 @@ use crate::parse_trait_sig::parse_trait_signature;
use crate::parse_trait_sig::MethodParseError;
use crate::parse_trait_sig::SignatureChanges;
use crate::parse_trait_sig::TypeTransform;
+use crate::transform::AssocTypeConversions;
+
mod parse_assoc_type;
mod parse_trait_sig;
mod syn_utils;
+mod transform;
macro_rules! abort {
($span:expr, $message:literal) => {
@@ -61,7 +62,7 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
let mut objectifiable_methods: Vec<(Signature, SignatureChanges)> = Vec::new();
- let mut assoc_type_conversions: HashMap<&Ident, &Type> = HashMap::new();
+ let mut assoc_type_conversions = AssocTypeConversions::default();
for item in &original_trait.items {
if let TraitItem::Type(assoc_type) = item {
@@ -77,7 +78,7 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream {
)
}
Ok((ident, type_)) => {
- assoc_type_conversions.insert(ident, type_);
+ assoc_type_conversions.0.insert(ident, type_);
}
}
}