-
Notifications
You must be signed in to change notification settings - Fork 13.3k
TRPL: Document that Send and Sync are automatically derived #28581
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
Comments
Does someone need to work on this, or is there already a PR? I'd like to do this. |
A PR would link to the issue. Nothing has linked here, so go for it. |
Perhaps it could go with a mention of |
Actually, |
Yes, but still it's nowhere in the book, it's a very common and useful attribute, deserves a mention IMO, and would go well with the Send and Sync stuff in a section or subsection. |
I totally agree that it deserves a mention in the book... But I think it could be mentioned in a new sub-section named "Popular attributes" or something in Attributes section... Open a new issue, @leodasvacas |
As far as I can tell, there is no documentation outside of the Rustonomicon that says that
Send
andSync
are automatically derived on datatypes that consist solely ofSend
andSync
members, and that all primitives other than raw pointers areSend + Sync
.So it is a natural worry for newcomers that the language is less thread-usable than it is (i.e., that libraries will forget to manually implement
Send + Sync
, and be pathologically safe by being unusable across threads), and it's hard to clarify that. (I only found this part of the 'nomicon throughgit grep
; the obvious Google results for 'rust send and sync' didn't have a clear statement that they were automatically derived.)This might be as easy as copying the two 'nomicon paragraphs starting with "Send and Sync are also automatically derived traits" into concurrency.md or so; there's no nontrivial discussion of unsafety in them. I could also send in a PR adding an example of using a
Send + Sync
struct, if that would be helpful.The text was updated successfully, but these errors were encountered: