diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -93,9 +93,10 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { } let mut type_converter = TypeConverter { - collections: method_attrs.collections, - assoc_type_conversions: HashMap::new(), trait_ident: original_trait.ident.clone(), + assoc_type_conversions: HashMap::new(), + collections: method_attrs.collections, + type_conversions: method_attrs.type_conversions, }; for item in &original_trait.items { @@ -122,9 +123,10 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { let mut objectifiable_methods: Vec<(Signature, SignatureChanges)> = Vec::new(); - for item in &original_trait.items { + for item in &mut original_trait.items { if let TraitItem::Method(method) = item { let mut signature = method.sig.clone(); + match convert_trait_signature(&mut signature, &type_converter) { Ok(parsed_method) => objectifiable_methods.push((signature, parsed_method)), Err((span, err)) => match err { @@ -169,7 +171,7 @@ pub fn dynamize(_attr: TokenStream, input: TokenStream) -> TokenStream { return abort!(span, "dynamize does not support qualified associated types") } MethodError::Transform(TransformError::SelfQualifiedAsOtherTrait) => { - return abort!(span, "dynamize does not support Self qualified as another trait") + return abort!(span, "dynamize does not know how to convert this type (you can tell it with #[convert])") } MethodError::UnconvertedAssocType => { return abort!(span, "dynamize does not support associated types here") @@ -471,6 +473,11 @@ impl TypeTransform { quote! {#arg.into_iter().map(|(#(#idents),*)| (#(#transforms),*)).collect()} } TypeTransform::NoOp => arg, + TypeTransform::Verbatim(convert) => { + let ident = &convert.ident; + let block = &convert.block; + quote! { {let #ident = #arg; #block }} + } } } } |