Relax Sync bound on Fut required on sse::upgrade#647
Relax Sync bound on Fut required on sse::upgrade#647Fishrock123 merged 2 commits intohttp-rs:masterfrom
Conversation
async_std::spawn doesn't seem to require a Sync bound on any Futures used on it. tide::sse::upgrade will just spawn the Future returned by the Fn parameter. With this in mind, the Sync bound on that returned Future seems unnecessary.
jbr
left a comment
There was a problem hiding this comment.
As mentioned in discord, this seems reasonable to me. The only thing we do with this future is hand it to async_std::task::spawn, so if it doesn't care about Sync-ness, maybe we don't need to either?
This commit also removes a PhantomData field from the SseEndpoint struct, since it doesn't seem to be required and it was turning the type !Sync. Removing it make the type Sync again, and allows us to remove the Sync bound from the returned Fut from the handler function.
|
I pushed an extra change making In order to do so I had to remove an apparently unnecessary There's still a |
Fishrock123
left a comment
There was a problem hiding this comment.
I'm not sure I 100% understand but you seem to need it and it compiles so I'm going to call it ok and worst comes to worst if something goes wrong then we can always revert it.
Description
Relax Sync bound on Fut required on sse::upgrade
Motivation and Context
async_std::spawndoesn't seem to require aSyncbound on anyFuturesused on it.
tide::sse::upgradewill justspawntheFuturereturned bythe
Fnparameter. With this in mind, theSyncbound on that returnedFutureseems unnecessary.This, in my experience, seems to conflict with any usages of
async-traitwithin that future, sinceasync-traitrelated futures don't appear to be Sync. The main README in theasync-traitrepo seems to suggest the sameHow Has This Been Tested?
The code compiles and my project is happy. Not sure how to test this, but I'm open to suggestions!
Types of changes
Checklist: