Skip to content

Commit 45cb1ff

Browse files
committed
comments from nostarch
1 parent 85fd039 commit 45cb1ff

File tree

2 files changed

+365
-297
lines changed

2 files changed

+365
-297
lines changed

nostarch/chapter01.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ well as how they work behind the scenes.
2626
## Contributing to the book
2727

2828
This book is open source. If you find an error, please don’t hesitate to file an
29-
issue or send a pull request [on GitHub].
29+
issue or send a pull request on GitHub at *https://github.com/rust-lang/book*.
3030

31-
[on GitHub]: https://github.com/rust-lang/book
31+
<!--[on GitHub]: https://github.com/rust-lang/book--> <!-- Where these links
32+
occur, could you pull the actual link and place it in a sentence, like above?
33+
That will make it easier for us to know what you want printed in the actual
34+
book, and what's just going up on the online version -->
3235

3336
## Installation
3437

@@ -65,6 +68,10 @@ If you're on Windows, please download the appropriate [installer][install-page].
6568

6669
[install-page]: https://www.rust-lang.org/install.html
6770

71+
<!-- Are there are options you'd recommend clicking, too? There are two
72+
download options: GNU and MSVC, what's the difference? What should the reader
73+
choose? -->
74+
6875
### Uninstalling
6976

7077
Uninstalling Rust is as easy as installing it. On Linux or Mac, just run
@@ -99,7 +106,7 @@ If you don't and you're on Windows, check that Rust is in your `%PATH%` system
99106
variable. If it isn't, run the installer again, select "Change" on the "Change,
100107
repair, or remove installation" page and ensure "Add to PATH" is checked.
101108

102-
If not, there are a number of places where you can get help. The easiest is
109+
If it still isn't working, there are a number of places where you can get help. The easiest is
103110
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
104111
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
105112
(a silly nickname we call ourselves) who can help you out. Other great resources
@@ -126,7 +133,7 @@ tradition.
126133

127134
> Note: This book assumes basic familiarity with the command line. Rust itself
128135
> makes no specific demands about your editing, tooling, or where your code
129-
> lives, so if you prefer an IDE to the command line, that's an option.
136+
> lives, so if you prefer an IDE to the command line, feel free to use your favored IDE.
130137
131138
### Creating a Project File
132139

@@ -146,6 +153,9 @@ $ cd hello_world
146153
> your home directory may not work.
147154
> Consult the documentation for your shell for more details.
148155
156+
<!-- Could you be more specific on Windows instructions? For me, I just had to
157+
remove the tilde and it worked perfectly -->
158+
149159
### Writing and Running a Rust Program
150160

151161
Next, make a new source file and call it *main.rs*. Rust files always end with
@@ -169,6 +179,9 @@ $ rustc main.rs
169179
$ ./main
170180
Hello, world!
171181
```
182+
<!-- On Windows I had to run `rustc main.rs` first to create a main.exe file,
183+
and just typed "main" without ./ or `exe` to run it. Can you be more specific
184+
here, maybe just lay out the windows version, since it's so short? -->
172185

173186
On Windows, just replace `main` with `main.exe`. Regardless of your operating
174187
system, you should see the string `Hello, world!` print to the terminal. If you
@@ -189,12 +202,12 @@ fn main() {
189202
These lines define a *function* in Rust. The `main` function is special: it's
190203
the first thing that is run for every executable Rust program. The first line
191204
says, “I’m declaring a function named `main` that takes no arguments and
192-
returns nothing.” If there were arguments, they would go inside the parentheses
193-
(`(` and `)`). We aren’t returning anything from this function, so we have
205+
returns nothing.” If there were arguments, they would go inside the parentheses,
206+
`(` and `)`. <!--- We aren’t returning anything from this function, so we have
194207
omitted the return type entirely. If there was a return type, there would be a
195-
`->` and the return type after the parentheses.
208+
`->` and the return type after the parentheses. -->
196209

197-
Also note that the function body is wrapped in curly braces (`{` and `}`). Rust
210+
Also note that the function body is wrapped in curly braces, `{` and `}`. Rust
198211
requires these around all function bodies. It's considered good style to put
199212
the opening curly brace on the same line as the function declaration, with one
200213
space in between.
@@ -207,7 +220,7 @@ Inside the `main()` function:
207220

208221
This line does all of the work in this little program: it prints text to the
209222
screen. There are a number of details that are important here. The first is
210-
that it’s indented with four spaces, not tabs.
223+
that it’s indented with four spaces, not a tab.
211224

212225
The second important part is `println!()`. This is calling a Rust *macro*,
213226
which is how metaprogramming is done in Rust. If it were calling a function
@@ -252,6 +265,10 @@ On Windows, you'd enter:
252265
$ dir
253266
main.exe main.rs
254267
```
268+
<!-- This is different for me too -- on windows `ls` worked but `dir` gave me
269+
different information. However! My colleague also on Windows 10 couldn't get ls
270+
to work, but dir gave the wrong info. I think we may need to look at getting a
271+
tech reviewer to test Windows instructions -->
255272

256273
This shows we have two files: the source code, with the `.rs` extension, and the
257274
executable (`main.exe` on Windows, `main` everywhere else). All that's left to
@@ -260,6 +277,7 @@ do from here is run the `main` or `main.exe` file, like this:
260277
```bash
261278
$ ./main # or main.exe on Windows
262279
```
280+
<!-- `$ main` worked for me, without `./` or `exe` -->
263281

264282
If *main.rs* were your "Hello, world!" program, this would print `Hello,
265283
world!` to your terminal.
@@ -285,7 +303,7 @@ Cargo is Rust’s build system and package manager, and Rustaceans use Cargo to
285303
manage their Rust projects because it makes a lot of tasks easier. For example,
286304
Cargo takes care of building your code, downloading the libraries your code
287305
depends on, and building those libraries. We call libraries your code needs
288-
dependencies’ since your code depends on them.
306+
*dependencies*.
289307

290308
The simplest Rust programs, like the one we've written so far, don’t have any
291309
dependencies, so right now, you'd only be using the part of Cargo that can take
@@ -304,8 +322,8 @@ $ cargo --version
304322
```
305323

306324
If you see a version number, great! If you see an error like `command not
307-
found`, then you should look at the documentation for the way you installed
308-
Rust to determine how to install Cargo separately.
325+
found`, then you should look at the documentation for your method of installation
326+
to determine how to install Cargo separately.
309327

310328
### Creating a Project with Cargo
311329

@@ -326,8 +344,8 @@ $ cd hello_cargo
326344

327345
We passed the `--bin` argument to `cargo new` because our goal is to make an
328346
executable application, as opposed to a library. Executables are often called
329-
*binaries* (as in `/usr/bin`, if you’re on a Unix system). `hello_cargo` is the
330-
name we've chosen for our project, and Cargo creates its files in a directory
347+
*binaries* (as in `/usr/bin`, if you’re on a Unix system). We've given `hello_cargo` as the
348+
name for our project, and Cargo creates its files in a directory
331349
of the same name that we can then go into.
332350

333351
If we list the files in the `hello_cargo` directory, we can see that Cargo has
@@ -412,6 +430,7 @@ This should have created an executable file in `target/debug/hello_cargo` (or `t
412430
$ ./target/debug/hello_cargo # or ./target/debug/hello_cargo.exe on Windows
413431
Hello, world!
414432
```
433+
<!-- Windows needs to use \ without the . -->
415434

416435
Bam! If all goes well, `Hello, world!` should print to the terminal once more.
417436

@@ -439,7 +458,7 @@ $ cargo run
439458
Hello, world!
440459
```
441460

442-
Notice that this time, we didn't see the output that Cargo was compiling
461+
Notice that this time, we didn't see the output telling us that Cargo was compiling
443462
`hello_cargo`. Cargo figured out that the files haven’t changed, so it just ran
444463
the binary. If you had modified your source code, Cargo would have rebuilt the
445464
project before running it, and you would have seen something like this:
@@ -477,7 +496,7 @@ projects composed of multiple crates, it’s much easier to let Cargo coordinate
477496
the build. With Cargo, you can just run `cargo build`, and it should work the
478497
right way. Even though this project is simple, it now uses much of the real
479498
tooling you’ll use for the rest of your Rust career. In fact, you can get
480-
started with virtually all Rust projects you might find that you want to work
499+
started with virtually all Rust projects you want to work
481500
on with the following commands:
482501

483502
```bash

0 commit comments

Comments
 (0)