-
Notifications
You must be signed in to change notification settings - Fork 64
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
can we use &dyn to circumvent: error[E0562]: impl Trait only allowed in function and inherent method return types, not in Fn trait param
#498
Comments
error[E0562]:
impl Trait only allowed in function and inherent method return types, not in
Fn trait param
``error[E0562]:
impl Trait only allowed in function and inherent method return types, not in
Fn trait param
``
error[E0562]:
impl Trait only allowed in function and inherent method return types, not in
Fn trait param
``error[E0562]: \
impl Trait\ only allowed in function and inherent method return types, not in \
Fn\ trait param
error[E0562]: \
impl Trait\ only allowed in function and inherent method return types, not in \
Fn\ trait param
error[E0562]:
impl Trait
only allowed in function and inherent method return types, not in
Fn
trait param
error[E0562]:
impl Trait
only allowed in function and inherent method return types, not in
Fn
trait param
error[E0562]: impl Trait only allowed in function and inherent method return types, not in Fn trait param
sorry about the title spam. |
|
I forgot to mention one other option: #[automock]
impl Bar {
#[concretize]
fn baz<T: Foo>(&self, _f: &T) {}
} |
perfect, that's exactly what I was looking for. Will it also work for |
I'm not sure. The |
Do you have any ETA for releasing At the very least, there could be a 0.12.0-beta.1 release (or 0.11.5-beta.1) which won't be pickup automatically by cargo, so only those that opt-in will be getting it. It'd also allow us to provide feedback on the new features! |
I'm going to release it later today. BTW, RPITIT looks very useful, and Mockall might have some additional work to do to support that. |
Ran into this issue. My understanding of the problem here is not that great. But I also don't understand the recommended solution: you say "Just add the + 'static to your original function signature." In the OP's code his original function was
... so how could we "add the + 'static" to that to solve the problem? I mean, could you possibly show the new function signature? I tried to do this with my signature: Failing due to error in question: I get a different failure after this:
I'm assuming this is just too complicated (with the closure-as-parameter) ... but maybe you can suggest something? |
You already answered your first question: convert the |
My code uses
&impl Trait
function arguments, but automock struggles with it (see example code below). If I use generics, mockall forces me to add+ 'static
, and I don't know how that interacts with my other code.However, I can use custom
&dyn Trait
mocks that seem to work. Is this a reasonable approach?Example
The text was updated successfully, but these errors were encountered: