Skip to content

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

Merged
merged 3 commits into from
Jul 31, 2014
Merged

doc: Monty Hall simulation for std::rand #16041

merged 3 commits into from
Jul 31, 2014

Conversation

treeman
Copy link
Contributor

@treeman treeman commented Jul 28, 2014

A larger example for std::rand.

A larger example for std::rand
free_doors(vec![choice, open])[0]
}

fn free_doors(blocked: Vec<uint>) -> Vec<uint> {
Copy link
Member

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])).

@alexcrichton
Copy link
Member

Looks good to me! Could you squash the commits together?


struct SimulationResult {
win: bool,
switch: bool
Copy link
Member

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

@treeman
Copy link
Contributor Author

treeman commented Jul 28, 2014

@steveklabnik currently the head documentation is surrounded in /*! ... */, which might confuse a bit with ///. Usually we use //! but I chose not to change it. I can if you want of course?

@steveklabnik
Copy link
Member

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 //!, since that's the preferred style.

}

fn main() {
// The estimation will be more accuraty with more simulations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "accurate", not "accuraty"

@treeman
Copy link
Contributor Author

treeman commented Jul 28, 2014

It renders fine as a doc comment the way it is now, but I will change it to use //! across the board.

@treeman
Copy link
Contributor Author

treeman commented Jul 28, 2014

Also fixed the typo mentioned by @pnkfelix, but rebased away.

@treeman
Copy link
Contributor Author

treeman commented Jul 31, 2014

@brson it seems this got stuck as "discussing" at bors.

bors added a commit that referenced this pull request Jul 31, 2014
A larger example for `std::rand`.
@bors bors closed this Jul 31, 2014
@bors bors merged commit 23b84e5 into rust-lang:master Jul 31, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 11, 2023
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.
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

Successfully merging this pull request may close these issues.

6 participants