test-context icon indicating copy to clipboard operation
test-context copied to clipboard

Make Send bound optional for AsyncTestContext

Open funbiscuit opened this issue 2 years ago • 1 comments

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 avatar Apr 09 '23 10:04 funbiscuit

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

funbiscuit avatar Apr 09 '23 12:04 funbiscuit

@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 avatar Feb 22 '24 17:02 JasterV

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 avatar Feb 25 '24 22:02 JasterV