-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility with trait-variant for automock #639
Comments
This would certainly be a handy feature to have. Basically, we need |
@asomers The last example does not compile:
|
@asomers Sorry I misunderstood your previous question, the third example does indeed compile, and The problem is that the fourth example (the last one) doesn't compile, where the trait_variant macro expands after automock (same way as with async_trait on the first example, which compiles just fine). That way we don't have to I've made a PR where the |
This crate automock already has direct support for async_trait (#183), allowing you to place the async_trait macro after the automock (doc) which allows you to directly return the future output when mocking:
If you place the async_trait to be resolved before, you have to return the pinned box future on the mocks, which allows for further customization:
That's great! And I was hoping now that trait-variant is available as part of Rust 1.75 stabilization of async fn in traits that it could work the same way.
This is working:
But this is failing:
If the trait variant annotation is removed it works as expected, and if the annotation is added back to the expanded trait it works fine also, so I guess this is not a big change, but I'm not familiar with the codebase.
It would be great to support it the same way in order to allow for an easy migration from async_trait to trait_variant, without having to fix all of the tests.
The text was updated successfully, but these errors were encountered: