Closed wackazong closed 1 year ago
I changed the syntax to generic functions which compiles just fine:
use std::fmt::Debug;
use entrait::entrait;
pub trait MyTrait: Debug {}
#[entrait(Foo, mock_api=FooMock)]
fn foo<D, T: MyTrait>(_: &D, _foo: &T) -> i32 {
unimplemented!()
}
#[entrait(Bar, mock_api=BarMock)]
fn bar<D, T: MyTrait>(_: &D, _bar: &mut T) -> i32 {
unimplemented!()
}
fn main() {}
Sidenote: when using the module version of the entrait macro, I need to use distinct generic type parameters for all functions. This example will not compile and complain about the name `T` is already used for a generic parameter in this item's generic parameters
use std::fmt::Debug;
use entrait::entrait;
pub trait MyTrait: Debug {
fn foor();
}
#[entrait(pub Foo, mock_api=mock, no_deps)]
mod my_module {
pub fn foo<T: super::MyTrait>(_foo: &T) -> i32 {
unimplemented!()
}
pub fn bar<T: super::MyTrait>(_bar: &mut T) -> i32 {
unimplemented!()
}
}
fn main() {}
Both functions give me compiler errrors for
cargo build --tests
. I use entrait with theunimock
feature as dependency. Is there a way to make them work withentrait
/unimock
?Errors: