Removed unnecessary unsafe impl of Send and Sync#66
Open
peter-lyons-kehl wants to merge 2 commits intoProtocol-Lattice:mainfrom
Open
Removed unnecessary unsafe impl of Send and Sync#66peter-lyons-kehl wants to merge 2 commits intoProtocol-Lattice:mainfrom
peter-lyons-kehl wants to merge 2 commits intoProtocol-Lattice:mainfrom
Conversation
Member
|
Hi, thank you for your contribution, I will check it later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hi Kamil,
ShardedCachedefined aspub struct ShardedCache<V> {..., orpub struct ShardedCache<V: Clone> {...as that is, withoutVbeing bound bySend+Sync; but later you changed it to includeVto be bound by `Send+Sync?Either way, good learning: While having a struct/enum/union defined with the least restricting bounds is a common and recommended practice, unfortunately, it doesn't auto infer
SendandSync, hence there would be a need forunsafe impl. But since theShardedCachedoes haveSend+Syncbound onV,SendandSyncare auto-inferred.ShardedCacheis indeedSync+Send. I do NOT think that such a test is necessary, but if you do want to include it, do so. Maybe you hadunsafe implso that it would be clear/"guaranteed" thatSendandSyncwere intentional. This test could indicate it instead.But, if you don't add this test, then
SendandSyncare required by other parts of the code. For example, when I changedShardedCacheNOT to make itSend+Syncby (shortenedgit diffhere):(and I've modified the
newconstructor accordingly), then many other parts of the code failed to build, like:So, it should be clear to anyone that
Send+Syncis intentional.Checklist: