@@ -26,9 +26,12 @@ well as how they work behind the scenes.
26
26
## Contributing to the book
27
27
28
28
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 * .
30
30
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 -->
32
35
33
36
## Installation
34
37
@@ -65,6 +68,10 @@ If you're on Windows, please download the appropriate [installer][install-page].
65
68
66
69
[ install-page ] : https://www.rust-lang.org/install.html
67
70
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
+
68
75
### Uninstalling
69
76
70
77
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
99
106
variable. If it isn't, run the installer again, select "Change" on the "Change,
100
107
repair, or remove installation" page and ensure "Add to PATH" is checked.
101
108
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
103
110
[ the #rust IRC channel on irc.mozilla.org] [ irc ] , which you can access through
104
111
[ Mibbit] [ mibbit ] . Click that link, and you'll be chatting with other Rustaceans
105
112
(a silly nickname we call ourselves) who can help you out. Other great resources
@@ -126,7 +133,7 @@ tradition.
126
133
127
134
> Note: This book assumes basic familiarity with the command line. Rust itself
128
135
> 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 .
130
137
131
138
### Creating a Project File
132
139
@@ -146,6 +153,9 @@ $ cd hello_world
146
153
> your home directory may not work.
147
154
> Consult the documentation for your shell for more details.
148
155
156
+ <!-- Could you be more specific on Windows instructions? For me, I just had to
157
+ remove the tilde and it worked perfectly -->
158
+
149
159
### Writing and Running a Rust Program
150
160
151
161
Next, make a new source file and call it * main.rs* . Rust files always end with
@@ -169,6 +179,9 @@ $ rustc main.rs
169
179
$ ./main
170
180
Hello, world!
171
181
```
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? -->
172
185
173
186
On Windows, just replace ` main ` with ` main.exe ` . Regardless of your operating
174
187
system, you should see the string ` Hello, world! ` print to the terminal. If you
@@ -189,12 +202,12 @@ fn main() {
189
202
These lines define a * function* in Rust. The ` main ` function is special: it's
190
203
the first thing that is run for every executable Rust program. The first line
191
204
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
194
207
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. -->
196
209
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
198
211
requires these around all function bodies. It's considered good style to put
199
212
the opening curly brace on the same line as the function declaration, with one
200
213
space in between.
@@ -207,7 +220,7 @@ Inside the `main()` function:
207
220
208
221
This line does all of the work in this little program: it prints text to the
209
222
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 .
211
224
212
225
The second important part is ` println!() ` . This is calling a Rust * macro* ,
213
226
which is how metaprogramming is done in Rust. If it were calling a function
@@ -252,6 +265,10 @@ On Windows, you'd enter:
252
265
$ dir
253
266
main.exe main.rs
254
267
```
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 -->
255
272
256
273
This shows we have two files: the source code, with the ` .rs ` extension, and the
257
274
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:
260
277
``` bash
261
278
$ ./main # or main.exe on Windows
262
279
```
280
+ <!-- `$ main` worked for me, without `./` or `exe` -->
263
281
264
282
If * main.rs* were your "Hello, world!" program, this would print `Hello,
265
283
world!` to your terminal.
@@ -285,7 +303,7 @@ Cargo is Rust’s build system and package manager, and Rustaceans use Cargo to
285
303
manage their Rust projects because it makes a lot of tasks easier. For example,
286
304
Cargo takes care of building your code, downloading the libraries your code
287
305
depends on, and building those libraries. We call libraries your code needs
288
- ‘ dependencies’ since your code depends on them .
306
+ * dependencies* .
289
307
290
308
The simplest Rust programs, like the one we've written so far, don’t have any
291
309
dependencies, so right now, you'd only be using the part of Cargo that can take
@@ -304,8 +322,8 @@ $ cargo --version
304
322
```
305
323
306
324
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.
309
327
310
328
### Creating a Project with Cargo
311
329
@@ -326,8 +344,8 @@ $ cd hello_cargo
326
344
327
345
We passed the ` --bin ` argument to ` cargo new ` because our goal is to make an
328
346
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
331
349
of the same name that we can then go into.
332
350
333
351
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
412
430
$ ./target/debug/hello_cargo # or ./target/debug/hello_cargo.exe on Windows
413
431
Hello, world!
414
432
```
433
+ <!-- Windows needs to use \ without the . -->
415
434
416
435
Bam! If all goes well, ` Hello, world! ` should print to the terminal once more.
417
436
@@ -439,7 +458,7 @@ $ cargo run
439
458
Hello, world!
440
459
```
441
460
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
443
462
` hello_cargo ` . Cargo figured out that the files haven’t changed, so it just ran
444
463
the binary. If you had modified your source code, Cargo would have rebuilt the
445
464
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
477
496
the build. With Cargo, you can just run ` cargo build ` , and it should work the
478
497
right way. Even though this project is simple, it now uses much of the real
479
498
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
481
500
on with the following commands:
482
501
483
502
``` bash
0 commit comments