impl Sync for RouterIntoService #3552
Closed
+5
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an unsafe impl of Sync for RouterIntoService
Motivation
Whilst trying to build some testing apparatus for my project, I wanted to pass a reference to something containing
RouterIntoService<Body>by reference into an async method. Doing so made theFuturefor that method notSend, becauseRouterIntoService<Body>was notSync. This was problematic for me, so I looked into your source and found that the body typeBwas only held onto as aPhantomData, which to my mind means it shouldn't affect theSync-ness of the data structure. Looking further into the state typeS, that looks like it's used in a dyn trait bound who's super traits already forceSendandSync, so I believe there's not a requirement onSto beSynchere either, but I might be mistaken on that.Solution
I just added a manual implementation to relax the
!Syncconstraint on the type. This should mean that in the future I don't need to manually annotate the types in my code.