Skip to content

Replace uint with u32 in trpl/guessing-game.md #20892

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 1 commit into from
Jan 16, 2015
Merged

Conversation

CarVac
Copy link
Contributor

@CarVac CarVac commented Jan 10, 2015

uint was recently deprecated, so in following the use of i32 in the first parts, replace all copies of uint with u32.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@@ -239,7 +239,7 @@ use std::rand;
fn main() {
println!("Guess the number!");

let secret_number = (rand::random::<uint>() % 100u) + 1u;
let secret_number = (rand::random::<u32>() % 100u) + 1u;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is currently breaking the build:

<anon>:10:50: 10:54 error: mismatched types: expected `u32`, found `usize` (expected u32, found usize)
<anon>:10     let secret_number = (rand::random::<u32>() % 100u) + 1u;
                                                           ^~~~
<anon>:10:58: 10:60 error: mismatched types: expected `u32`, found `usize` (expected u32, found usize)
<anon>:10     let secret_number = (rand::random::<u32>() % 100u) + 1u;
                                                                   ^~

because the u suffix means that those literals are of type usize still. As it turns out, these suffixes can actually be entirely removed now! E.g. this can become:

let secret_number = (rand::random::<u32>() % 100) + 1;

both here, and at the several other occurrences of this same line below here, and that will fix it. :)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that sounds like the plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I make another commit and issue a separate pull request?

I'm not fully sure of the procedure.

Copy link
Contributor

Choose a reason for hiding this comment

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

So the best way to go about this is to just make the additional changes to this file, and then:

$ git add guessing-game.md
$ git commit --amend
(do the commit)
$ git push -f origin master

That will update your PR with a single commit containing both the old changes and the new ones! If you want to check the new commit to make sure it's all correct, you can git show HEAD between committing and pushing in the above instructions to see what you're about to force-push.

uint was recently deprecated, so in following the use of i32 at first,
replace all references to uint with u32.

Also change literals from e.g. 100u to 100, so that they are no longer
usize.
bors added a commit that referenced this pull request Jan 14, 2015
Replace uint with u32 in trpl/guessing-game.md

Reviewed-by: steveklabnik
bors added a commit that referenced this pull request Jan 14, 2015
Replace uint with u32 in trpl/guessing-game.md

Reviewed-by: steveklabnik
bors added a commit that referenced this pull request Jan 15, 2015
Replace uint with u32 in trpl/guessing-game.md

Reviewed-by: steveklabnik
bors added a commit that referenced this pull request Jan 15, 2015
Replace uint with u32 in trpl/guessing-game.md

Reviewed-by: steveklabnik
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 15, 2015
`uint` was recently deprecated, so in following the use of `i32` in the first parts, replace all copies of `uint` with `u32`.
@bors bors merged commit 9302dc5 into rust-lang:master Jan 16, 2015
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