Skip to content
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

Functions with lifetime argument can't be mocked #2

Open
rayslava opened this issue Jun 10, 2022 · 7 comments
Open

Functions with lifetime argument can't be mocked #2

rayslava opened this issue Jun 10, 2022 · 7 comments

Comments

@rayslava
Copy link

Functions like

#[mry::mry]
fn test<'a>(arg: &'a str) -> &'a str {
    arg
}

causes error[E0261]: use of undeclared lifetime name 'a, and removing #[mry::mry] fixes the error.

Is this a bug or there's some additional syntax for this case?

@ryo33
Copy link
Owner

ryo33 commented Jun 10, 2022

Thanks for submitting. It’s just not implemented. I’ll fix this soon. Issues like this are helpful for making mry more mature.

@rayslava
Copy link
Author

Okay, I see. And thank you for the framework!
It's really convenient and easy-to-use for small projects.

@ryo33
Copy link
Owner

ryo33 commented Jun 10, 2022

I've published mry 0.2.4, the problem should be resolved. Please reopen this issue if not resolved.
There are still many missing features in mry that I am not aware of, so I'm glad if you open issues for any problems with mry.

@ryo33 ryo33 closed this as completed Jun 10, 2022
@rayslava
Copy link
Author

rayslava commented Jun 13, 2022

Still no success...
Apparently I've created a code bad enough to brake your macros :)
https://github.com/rayslava/ytdlpwui/runs/6866944541?check_suite_focus=true#step:7:82

@ryo33
Copy link
Owner

ryo33 commented Jun 14, 2022

Oh, zero-copy things are a bit difficult in current mry features. It's because parameters must be 'static to be stored to call logs.
I think we need an attribute like #[mry::into(StaticStruct)] to convert a value with not 'static lifetime into something 'static one.

@ryo33
Copy link
Owner

ryo33 commented Jun 14, 2022

We need, otherwise, something like #[mry::no_call_log)] to make call logs unavailable.
Do you need to assert the function how called with assert_called? It uses call logs so needs 'static lifetime.

@ryo33
Copy link
Owner

ryo33 commented Jul 15, 2022

I've decided to support lifetime arguments in the future. I have thought about how to do it. It requires a few API changes.

@ryo33 ryo33 reopened this Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants