-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Guessing Game: Paragraph now superfluous in Rust 2018? #1662
Comments
The associated code snippet (Listing 2-3) however, does not compile with the latest stable rustc/crate version 1.31.0 because of the missing extern statement ("extern crate rand;"). |
The code snippet compiles fine for me. But I'm guessing that's because I'm a Rust n00b, installed rustc 1.31.0 as my initial installation of Rust, and have a line 'edition = "2018"' automatically included in my Cargo.toml file when I do "cargo new". If I remove that line or change 2018 to 2015 then I get the same behavior as you, i.e., a compilation error referencing a missing "extern crate rand;" statement. My assumption is that the current online version of the Rust docs is intended to be for Rust 2018 users. If that's the case, then for those users the code snippet can and arguably should leave out the "extern crate" statement, the paragraph that (indirectly) references that statement should be removed, and the following paragraph rewritten slightly. |
Ah, that explains it. I had created the 'guessing_game' project a few months back using an older version of cargo, and hence the 'edition' property was missing from the toml. Encountered this error when revisiting the project to brush up the basics :) The project compiles fine after adding 'edition = "2018"'. Maybe the doc authors can also update the Filename: Cargo.toml code snippet with the 'edition' property to avoid confusion? |
@Shanks512 This should be fixed in the newest version of the docs |
In the Rust 2018 edition discussion of the guessing game, there are two paragraphs as follows:
I'm guessing that the first paragraph is no longer needed, because Rust 2018 doesn't need the "extern crate" statement (or whatever it is).
The text was updated successfully, but these errors were encountered: