Skip to content

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

Closed
geofft opened this issue Sep 22, 2015 · 6 comments
Closed

TRPL: Document that Send and Sync are automatically derived #28581

geofft opened this issue Sep 22, 2015 · 6 comments

Comments

@geofft
Copy link
Contributor

geofft commented Sep 22, 2015

As far as I can tell, there is no documentation outside of the Rustonomicon that says that Send and Sync are automatically derived on datatypes that consist solely of Send and Sync members, and that all primitives other than raw pointers are Send + 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 through git 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.

@Gankra Gankra added the A-book label Sep 22, 2015
@alexispurslane
Copy link
Contributor

Does someone need to work on this, or is there already a PR? I'd like to do this.

@Havvy
Copy link
Contributor

Havvy commented Sep 23, 2015

A PR would link to the issue. Nothing has linked here, so go for it.

@leoyvens
Copy link
Contributor

Perhaps it could go with a mention of derive? It seems to be nowhere in the book, and it's another thing most types can get for free.

@critiqjo
Copy link

Actually, derive is documented in the reference, which is linked to from Attributes section of the book (see the last para)... 😄

@leoyvens
Copy link
Contributor

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.

@critiqjo
Copy link

I totally agree that it deserves a mention in the book... But Send and Sync are automatically derived, so isn't it unrelated to derive?

I think it could be mentioned in a new sub-section named "Popular attributes" or something in Attributes section... Open a new issue, @leodasvacas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants