-
Notifications
You must be signed in to change notification settings - Fork 6
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
Returning &Self #9
Comments
Thanks for pointing this out! Unfortunately, Rust's hygenic macros prevent us from being able to mock traits/methods which use the As for the second compiler error, I don't have an immediate explanation/solution. I will look into this tomorrow evening (UTC) and update this issue with whatever I find. |
Thanks for the reply, @DonaldWhyte! The For the lifetime issue, the compiler doesn't know that the lifetime of the reference being returned is tied to that of the (implied) Hopefully some kind of workaround will spring to mind for the lifetimes issue! Fingers crossed... :) |
Hi, @DonaldWhyte. Checking in to see if there is any news before I try crafting a home-grown workaround? |
Hey @U007D! I haven't forgotten about this. I've been spending most of the time I have available on double on implementing a concise/expressive call pattern matching API (inspired by Google Mock's). That'll land into master and be deployed within the next couple of days, so I can begin to look at this again. Recapping the two issues, we have:
Unfortunately, I think solving (1) is out of reach at the time of writing. I believe Rust's hygenic macros are not sophisticated enough for this. There's a probably a hacky workaround that half solves the problem, but I think solving (2) is a higher priority. (2) is a big problem. Currently, any functions that return references cannot be mocked. My proposal for this is for the generated mock (there's one There are some subtleties and corner cases to handle. These are the cases where |
Thank you for the update, @DonaldWhyte! Yes, those are the two main issues. I look forward to the PR once you have it ready! Thanks again for the update. |
+1 on this.. also curious about supporting mocking for traits with associated types (https://doc.rust-lang.org/book/second-edition/ch19-03-advanced-traits.html) |
Given the following trait:
I have tried:
but this yields:
I tried:
which helps, but I am still left with:
How can I make a mock of
Chal
usingdouble
?The text was updated successfully, but these errors were encountered: