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
trait A
is not implemented for Box<dyn A>
#363
Comments
Yeah, I think that will work. Since you've already delved in so far, would you like to submit a PR? You can extend the test case that's already in mockall/tests/mock_return_dyn_trait.rs . |
No problem. I'll try opening a PR later. |
frank-king
pushed a commit
to frank-king/mockall
that referenced
this issue
Feb 25, 2022
frank-king
pushed a commit
to frank-king/mockall
that referenced
this issue
Feb 25, 2022
frank-king
pushed a commit
to frank-king/mockall
that referenced
this issue
Feb 25, 2022
onalante-msft
pushed a commit
to onalante-msft/mockall
that referenced
this issue
May 5, 2022
onalante-msft
pushed a commit
to onalante-msft/mockall
that referenced
this issue
May 7, 2022
* fix `Box<dyn A>: A` required in returning `&dyn A` for asomers#363 * Tweak trait object return test * Update changelog * Add return value description for dedynify
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi folks, I met a compile error when doing this:
The compile error is:
I ran
cargo expand
to see what was happening, and find that:Here
Expectation::call
returns&Box<dyn A>
butB::as_a
requires&dyn A
, andBox<dyn A>: A
is not satisfied.The solution is simple. I just add something like this:
Then it compiles.
But is it possible to make this change in the generated code in
MockFoo::as_a
?After that, there is no extra
impl<T: A + ?Sized> A for Box<T> {}
needed.The text was updated successfully, but these errors were encountered: