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

#[future] with type constraint of impl Trait supported? #293

Open
arichtman opened this issue Jan 24, 2025 · 2 comments
Open

#[future] with type constraint of impl Trait supported? #293

arichtman opened this issue Jan 24, 2025 · 2 comments

Comments

@arichtman
Copy link

Hi all - thanks so much for your crate and time 🙏🏼

From the code it looks like the #[future] macro should support impl Trait, yet I get a macro error. Expanded version works fine so the end is valid Rust. Not sure if this is intended to be supported though.

Image

@la10736
Copy link
Owner

la10736 commented Jan 24, 2025

Ok, maybe with the current implementation accept the ImplTrait is an error because the implementation doesn't take it in account. The correct implementation should be implement the impl syntactic sugar by add a new generic.

Thanks for reporting it.

Workaround

#[rstest]
#[tokio::test]
async fn rubbish<S: StateTrait>(#[future] common_state: S) -> () {} 

About the macro order: if you put #[tokio::test] before #[rstest] you're precluding the possibility to add cases, values and files.

@arichtman
Copy link
Author

Thanks! That's sorted me - I'll leave the issue for you to manage as you like :)

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