From 2d964b39da09ad82eccf09abdea73967bbff76f2 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 18 Mar 2023 21:26:54 +0100 Subject: feat: add support for generic traits --- macros/src/lib.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'macros/src/lib.rs') diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 36c6ad7..8106a8c 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -34,11 +34,20 @@ pub fn mock(input_stream: TokenStream) -> TokenStream }) .collect::>(); - let mock = Mock::new(mock_ident.clone(), input.mocked_trait, &method_items); + let mock = Mock::new( + mock_ident.clone(), + input.mocked_trait, + &method_items, + input.item_impl.generics.clone(), + ); - let expectations = method_items - .iter() - .map(|item_method| Expectation::new(&mock_ident, item_method)); + let expectations = method_items.iter().map(|item_method| { + Expectation::new( + &mock_ident, + item_method, + input.item_impl.generics.params.clone(), + ) + }); quote! { mod #mock_mod_ident { -- cgit v1.2.3-18-g5258