summaryrefslogtreecommitdiff
path: root/macros/src/mock.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-03-18 18:26:53 +0100
committerHampusM <hampus@hampusmat.com>2023-03-18 18:26:53 +0100
commit43e0bdb4cc598f199eacb63f755f30dc2108146b (patch)
tree66f6bfc7fff793e2b267564fc05db4494a9ca2af /macros/src/mock.rs
parentc48271aef7e6b0819c497f302127c161845a83d7 (diff)
feat: parse impl in mock macro as actual impl block
Diffstat (limited to 'macros/src/mock.rs')
-rw-r--r--macros/src/mock.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/macros/src/mock.rs b/macros/src/mock.rs
index 88d3434..1b6dd67 100644
--- a/macros/src/mock.rs
+++ b/macros/src/mock.rs
@@ -16,7 +16,6 @@ use syn::{
ReturnType,
Signature,
Token,
- TraitItemMethod,
Type,
TypePath,
TypeReference,
@@ -43,18 +42,15 @@ use crate::util::create_unit_type_tuple;
pub struct Mock
{
ident: Ident,
- mocked_trait: TypePath,
+ mocked_trait: Path,
expectations_fields: Vec<ExpectationsField>,
- item_methods: Vec<TraitItemMethod>,
+ item_methods: Vec<ImplItemMethod>,
}
impl Mock
{
- pub fn new(
- ident: Ident,
- mocked_trait: TypePath,
- item_methods: &[TraitItemMethod],
- ) -> Self
+ pub fn new(ident: Ident, mocked_trait: Path, item_methods: &[ImplItemMethod])
+ -> Self
{
let expectations_fields = item_methods
.iter()
@@ -179,7 +175,7 @@ impl ToTokens for ExpectationsField
}
}
-fn create_mock_function(item_method: TraitItemMethod) -> ImplItemMethod
+fn create_mock_function(item_method: ImplItemMethod) -> ImplItemMethod
{
let func_ident = &item_method.sig.ident;
@@ -247,7 +243,7 @@ fn create_mock_function(item_method: TraitItemMethod) -> ImplItemMethod
}
}
-fn create_expect_function(mock: &Ident, item_method: &TraitItemMethod) -> ImplItemMethod
+fn create_expect_function(mock: &Ident, item_method: &ImplItemMethod) -> ImplItemMethod
{
let signature = Signature::new(
format_ident!("expect_{}", item_method.sig.ident),