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
Allow mocking generic methods with non-'static return values #76
Comments
|
Hi @asomers ! Have you started working on this feature? If not, I may look into it. I need it to mock methods returning BoxFuture with lifetime. I didn't dig deep so far, sill looking at your code and trying stuff. But my last experiment replacing lifetimes in return types with static seems to work. Do you already have ideas on what is the right approach handling this case? |
|
Yeah, I'm already working on it. I've got it about 50% working. Could you share the signature of one of the methods you're trying to mock? I might stick it in the test case. |
|
Great! |
It's now possible to mock generic methods whose return values' lifetimes are chosen by the caller. This is especially useful for methods that return std::future::Future. There are presently two restrictions: 1) static methods and bare functions of this type are not supported 2) The expectations' return values must be 'static. That can often be worked-around via an unsafe lifetime transmute. Hopefully both of those restrictions will be lifted in time. Fixes #76
It's now possible to mock generic methods whose return values' lifetimes are chosen by the caller. This is especially useful for methods that return std::future::Future. There are presently two restrictions: 1) static methods and bare functions of this type are not supported 2) The expectations' return values must be 'static. That can often be worked-around via an unsafe lifetime transmute. Hopefully both of those restrictions will be lifted in time. Fixes #76
PR #48 added the ability to mock generic methods whose arguments had lifetime parameters. But it didn't handle the case of return values with lifetime parameters. So the following still doesn't work:
The text was updated successfully, but these errors were encountered: