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

Make Send bound optional for AsyncTestContext #20

Closed
wants to merge 2 commits into from

Conversation

funbiscuit
Copy link

AsyncTestContext was originally implemented by using #[async_trait::async_trait]. Unfortunately this forces futures to be Send which sometimes unfeasible.
I've added a separate feature to the create async_send which is on by default. This way by default crate behaves identically to previous version. But if you disable this feature then AsyncTestContext will be created with #[async_trait::async_trait(?Send)] which allows futures to be not Send.
I wasn't able to think about any other mechanism other than feature flag. It would be great if you come up with something and it won't be a breaking change.

@funbiscuit
Copy link
Author

Alternatively you can change default feature async_send to non-default feature async_nosend, don't know what would be better.

@JasterV
Copy link
Owner

JasterV commented Feb 22, 2024

@funbiscuit what is your use case? I think its reasonable that if you use async code, the data you work must implement Send. Otherwise you could run into weird race conditions

@JasterV
Copy link
Owner

JasterV commented Feb 25, 2024

I think the case you mention can be solved by just wrapping your types in an Arc. I will close this PR for now and we can reopen a new issue in the future if this is still relevant.

@JasterV JasterV closed this Feb 25, 2024
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

Successfully merging this pull request may close these issues.

2 participants