-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
TRPL: guessing game #25080
TRPL: guessing game #25080
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
the guessing game. Here’s how it works: Our program will generate a random | ||
integer between one and a hundred. It will then prompt us to enter a guess. | ||
Upon entering our guess, it will tell us if we’re too low or too high. Once we | ||
guess correctly, it will congratulate us. Sound good? |
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.
Sound good?
Sounds good?
Good read. I've added a few comments for questions and typos. Feel free to ignore my stylistic suggestions :) |
Thanks @killercup and @parir ! nits addressed |
05a8757
to
830ec24
Compare
|
||
# Generating a secret number | ||
|
||
Next, we need to generate a secret number. Rust does not include random |
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.
Perhaps "does not yet"? (we do plan on including it one day)
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.
It's hard. Text like that tends to get out of date, though I guess this phrasing does too. Hrm.
Amazing @steveklabnik! Only a few stylistic nits from me, but otherwise r=me |
Woot! About to board a plane, but I'll get on it tomorrow. I gotta get used to linking to more docs :) |
rather than do all the work of figuring out versions again. This lets you | ||
have a repeatable build automatically. | ||
|
||
What about when we _do_ want to use `v0.4.0`? Cargo has another command, |
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.
NB. if the code above is changed to rand = "0.3"
this section will need updating.
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.
Will it? rand = 0.3 will use 0.4 when it comes out, just like this.
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.
The specification "0.3" to cargo indicates "0.3 compatible" and because 0.4 is not compatible with 0.3 it won't automatically pick it up (e.g. I believe @huonw is correct here)
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.
"0.3.0"
is shorthand for "^0.3.0"
still, right? That should pick up 0.4.0
, to be compatible with ^
requirements. It won't pick up a 1.0.0
.
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.
Yes, but 0.3.0 is not semver compatible with 0.4.0, so it won't pick it up
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.
Where's this behavior documented? Breaking ^
seems really bad :/
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.
Cargo takes 0.x
to be the major releases for 0.
versions, otherwise there wouldn't be a way to make incompatible releases other than going straight to 1.0
. (docs)
In fact, strictly speaking even this is different to what semver really is:
Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable.
I.e. 0.3.1
is "meant" to be not compatible with 0.3.2
, although I prefer our scheme.
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.
Gotcha. Ouch :/ well, i'll write a patch for this later today, since this PR was merged. Thanks you two!
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 particular function returns a handle to the standard input for your | ||
terminal. More specifically, a [std::io::Stdin][iostdin]. | ||
|
||
[stdin]: http://doc.rust-lang.org/nightly/std/io/struct.Stdin.html |
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 reference and the above don't match (iostdin
vs stdin
) and this should use a relative path (../std/io/struct.Stdin.html
).
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.
nice catch
830ec24
to
ef1a123
Compare
@bors: r=alexcrichton rollup |
📌 Commit ef1a123 has been approved by |
…richton This also made me realize that I wasn't using the correct term, 'associated functions', rather than 'static methods'. So I corrected that in the method syntax chapter.
ef1a123
to
9d512fd
Compare
This also made me realize that I wasn't using the correct term, 'associated functions', rather than 'static methods'. So I corrected that in the method syntax chapter.
@bors: r=alexcrichton rollup |
📌 Commit 9d512fd has been approved by |
…richton This also made me realize that I wasn't using the correct term, 'associated functions', rather than 'static methods'. So I corrected that in the method syntax chapter.
This also made me realize that I wasn't using the correct term,
'associated functions', rather than 'static methods'. So I corrected
that in the method syntax chapter.