-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve example in the intro. #21020
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
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
ownership of any data it uses; we'll have more on the significance of | ||
this shortly.) This closure is executed in a new thread created by | ||
`spawn`. | ||
This program creates ten threads, who all print `Hello, world!`. The `scoped` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/who/which/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, my closures are people 😉
Addressed both nits. |
Thank you @bluss for the suggested implementation. Fixes rust-lang#20844
Improve example in the intro. Reviewed-by: alexcrichton
Improve example in the intro. Reviewed-by: alexcrichton
Improve example in the intro. Reviewed-by: alexcrichton
}); | ||
} | ||
}) | ||
}).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Join guards are collected in this example to show explicitly how the things work, right? The code will behave in exactly the same way if we would just leave them out. Am I correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if you don't collect
, the map
won't do anything, as it's lazy. If you switch to a for
, each guard drops out of scope on each iteration, so they end up executing serially anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, got it!
Improve example in the intro. Reviewed-by: alexcrichton
Thank you @bluss for the suggested implementation. Fixes rust-lang#20844
Thank you @bluss for the suggested implementation.
Fixes #20844