Closed jaysonsantos closed 1 year ago
Nope. Mockall cannot derive Clone. You'll have to mock it. And #[automock]
can't handle type bounds. You'll have to use mock!
instead. See https://github.com/asomers/mockall/blob/master/mockall/tests/mock_clone.rs . Also, if you want to automock an async_trait, you must be the #[automock]
attribute first, and #[async_trait]
second. See https://github.com/asomers/mockall/blob/master/mockall/tests/mock_async_trait.rs for an example of using mock!
with #[async_trait]
.
Thanks for the clarification @asomers !
Hi there, while trying to implement automock I stumbled on an issue, given this sample trait:
The code won't compile because the generated struct does not implement clone:
the generated struct is:
I wonder if it would be worth it to make
Authenticate_expectations
something likeArc<Mutex<MockAuthenticate_Authenticate>>
so it can be clonable and still hold a central reference for all expectations?