-
Notifications
You must be signed in to change notification settings - Fork 13.3k
doc: Monty Hall simulation for std::rand #16041
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
A larger example for std::rand
free_doors(vec![choice, open])[0] | ||
} | ||
|
||
fn free_doors(blocked: Vec<uint>) -> Vec<uint> { |
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.
This should be taking &[uint]
(since it's just reading them, no need to force an allocation; called like free_doors(&[car, choice])
).
Looks good to me! Could you squash the commits together? |
|
||
struct SimulationResult { | ||
win: bool, | ||
switch: bool |
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.
this should have a trailing comma
@steveklabnik currently the head documentation is surrounded in |
Well, what I was thinking was that if it was an example, we should show the code as a doc comment, since it's supposed to be documentation. But since it's inside other documentation, does this work? And yeah, we should switch to |
} | ||
|
||
fn main() { | ||
// The estimation will be more accuraty with more simulations |
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.
typo: "accurate", not "accuraty"
It renders fine as a doc comment the way it is now, but I will change it to use |
Also fixed the typo mentioned by @pnkfelix, but rebased away. |
@brson it seems this got stuck as "discussing" at bors. |
A larger example for `std::rand`.
Fix WideChar offsets calculation in `line-index` Fix rust-lang#15981. This PR addresses the issue with the WideChar's offset calculation, ensuring accurate line-specific positions during text analysis in the `lib/line-index` module. ## Changes Made - Corrected the calculation for `WideChar` offsets, ensuring they reflect positions within respective lines. - Added tests to verify the accuracy of `WideChar` offset calculations, and correct existing tests.
A larger example for
std::rand
.