Workaround for trait with associated types and lifetimes #575
Unanswered
dsomerfield-vendia
asked this question in
Questions
Replies: 2 comments 1 reply
-
It figures. After fighting with this for hours, I might have just figured it out. This manual mock seems to work:
I need to validate whether that is semantically the same as the inferred lifetime, but this gives me a path forward. I |
Beta Was this translation helpful? Give feedback.
0 replies
-
Issue #541 describes the same anonymous lifetime problem, and shows a workaround. As for |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a fairly complex case where I have to cast some associated types that have lifetimes. I'm not terribly surprised that automock can't figure it out, but I also haven't been able to figure out if there is a work-around. This is the an example of the situation that I can't mock:
I have tried to do a manual mock, but haven't been able to create it in a way that the mock! macro will accept. Here is the mock I tried to create:
When I manually mock, it doesn't seem to like code generated by mock!, specifically, the
Self
reference (ambiguous associated type
) and the inferred lifetime (missing lifetime specifier
). Is there anyway, I can provide some hints, or possibly make some assumption that will allow the generated code to be acceptable. Full example with full error message is here.Incidentally, the example is async, but it I have removed all async code and that doesn't seem to be affecting anything at this point.
Beta Was this translation helpful? Give feedback.
All reactions