Skip to content

Commit 7bb193c

Browse files
committed
Fixes as per @brson's review
1 parent 2f4fbb2 commit 7bb193c

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

src/doc/trpl/getting-started.md

+28-32
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ we’ll talk about Cargo, Rust’s build system and package manager.
77
# Installing Rust
88

99
The first step to using Rust is to install it. Generally speaking, you’ll need
10-
an internet connection to run the commands in this chapter, as we’ll be
10+
an Internet connection to run the commands in this chapter, as we’ll be
1111
downloading Rust from the internet.
1212

1313
We’ll be showing off a number of commands using a terminal, and those lines all
@@ -108,7 +108,7 @@ tier 3 platforms that will ever be!
108108
If we're on Linux or a Mac, all we need to do is open a terminal and type this:
109109

110110
```bash
111-
$ curl -sf -L https://static.rust-lang.org/rustup.sh | sh
111+
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
112112
```
113113

114114
This will download a script, and stat the installation. If it all goes well,
@@ -140,8 +140,7 @@ If you're on Windows, please download the appropriate [installer][install-page].
140140

141141
## Uninstalling
142142

143-
If you ever need to uninstall Rust for any reason, refer to this section to
144-
find out how. It's actually as easy as installing. On Linux or Mac, just run
143+
Uninstalling Rust is as easy as installing it. On Linux or Mac, just run
145144
the uninstall script:
146145

147146
```bash
@@ -163,11 +162,6 @@ You should see the version number, commit hash, and commit date.
163162

164163
If you do, Rust has been installed successfully! Congrats!
165164

166-
This installer also installs a copy of the documentation locally, so we can
167-
read it offline. On UNIX systems, `/usr/local/share/doc/rust` is the location.
168-
On Windows, it's in a `share/doc` directory, inside the directory to which Rust
169-
was installed.
170-
171165
If you don't and you're on Windows, check that Rust is in your %PATH% system
172166
variable. If it isn't, run the installer again, select "Change" on the "Change,
173167
repair, or remove installation" page and ensure "Add to PATH" is installed on
@@ -184,6 +178,11 @@ include [the user’s forum][users], and [Stack Overflow][stackoverflow].
184178
[users]: https://users.rust-lang.org/
185179
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
186180

181+
This installer also installs a copy of the documentation locally, so we can
182+
read it offline. On UNIX systems, `/usr/local/share/doc/rust` is the location.
183+
On Windows, it's in a `share/doc` directory, inside the directory to which Rust
184+
was installed.
185+
187186
# Hello, world!
188187

189188
Now that you have Rust installed, we'll help you write your first Rust program.
@@ -227,7 +226,7 @@ $ cd hello_world
227226
228227
## Writing and Running a Rust Program
229228

230-
Next, make a new source file next and call it *main.rs*. Rust files always end
229+
Next, make a new source file and call it *main.rs*. Rust files always end
231230
in a *.rs* extension. If you’re using more than one word in your filename, use
232231
an underscore to separate them; for example, you'd use *hello_world.rs* rather
233232
than *helloworld.rs*.
@@ -266,28 +265,26 @@ fn main() {
266265
```
267266

268267
These lines define a *function* in Rust. The `main` function is special: it's
269-
the beginning of every Rust program. The first line says, "I’m declaring a
270-
function named `main` that currently takes no arguments and returns nothing."
271-
If there were arguments, they would go inside the parentheses (`(` and `)`),
272-
and because we aren’t returning anything from this function, we can omit the
273-
return type entirely.
268+
the beginning of every Rust program. The first line says, I’m declaring a
269+
function named `main` that takes no arguments and returns nothing.” If there
270+
were arguments, they would go inside the parentheses (`(` and `)`), and because
271+
we aren’t returning anything from this function, we can omit the return type
272+
entirely.
274273

275274
Also note that the function body is wrapped in curly braces (`{` and `}`). Rust
276275
requires these around all function bodies. It's considered good style to put
277276
the opening curly brace on the same line as the function declaration, with one
278277
space in between.
279278

280-
Inside the `main()` function, is this line:
279+
Inside the `main()` function:
281280

282281
```rust
283282
println!("Hello, world!");
284283
```
285284

286285
This line does all of the work in this little program: it prints text to the
287286
screen. There are a number of details that are important here. The first is
288-
that it’s indented with four spaces, not tabs. If you configure your editor of
289-
choice to insert four spaces with the tab key, it will make your coding much
290-
more efficient.
287+
that it’s indented with four spaces, not tabs.
291288

292289
The second important part is the `println!()` line. This is calling a Rust
293290
*[macro]*, which is how metaprogramming is done in Rust. If it were calling a
@@ -304,7 +301,7 @@ complicated topic in a systems programming language, and this is a *[statically
304301
allocated]* string. We pass this string as an argument to `println!`, which
305302
prints the string to the screen. Easy enough!
306303

307-
[allocation]: the-stack-and-the-heap.html
304+
[statically allocated]: the-stack-and-the-heap.html
308305

309306
The line ends with a semicolon (`;`). Rust is an *[expression oriented]*
310307
language, which means that most things are expressions, rather than statements.
@@ -343,7 +340,7 @@ $ dir
343340
main.exe main.rs
344341
```
345342

346-
This would create two files: the source code, with a `.rs` extension, and the
343+
This shows we have two files: the source code, with an `.rs` extension, and the
347344
executable (`main.exe` on Windows, `main` everywhere else). All that's left to
348345
do from here is run the `main` or `main.exe` file, like this:
349346

@@ -361,7 +358,7 @@ give it to someone else, and they can run it even without Rust installed. If
361358
you give someone a `.rb` or `.py` or `.js` file, on the other hand, they need
362359
to have a Ruby, Python, or JavaScript implementation installed (respectively),
363360
but you only need one command to both compile and run your program. Everything
364-
is a tradeoff in language design, and Rust has made its choice.
361+
is a tradeoff in language design.
365362

366363
Just compiling with `rustc` is fine for simple programs, but as your project
367364
grows, you'll want to be able to manage all of the options your project has,
@@ -374,7 +371,7 @@ programs.
374371
Cargo is Rust’s build system and package manager, and Rustaceans use Cargo to
375372
manage their Rust projects. Cargo manages three things: building your code,
376373
downloading the libraries your code depends on, and building those libraries.
377-
We call libraries your code needs ‘dependencies’, since your code depends on
374+
We call libraries your code needs ‘dependencies’ since your code depends on
378375
them.
379376

380377
The simplest Rust programs don’t have any dependencies, so right now, you'd
@@ -442,9 +439,8 @@ Make sure to capitalize the `C` in `Cargo.toml`, or Cargo won't know what to do
442439
with the configuration file.
443440

444441
This file is in the *[TOML]* (Tom's Obvious, Minimal Language) format. TOML is
445-
similar to INI, but has some extra goodies. According to the TOML docs, TOML
446-
“aims to be a minimal configuration file format that's easy to read”, and so we
447-
chose it as the format Cargo uses.
442+
similar to INI, but has some extra goodies, and is used as Cargo’s
443+
configuration format.
448444

449445
[TOML]: https://github.com/toml-lang/toml
450446

@@ -494,9 +490,9 @@ Hello, world!
494490
```
495491

496492
Notice that this example didn’t re-build the project. Cargo figured out that
497-
the hasn’t changed, and so it just ran the binary. If you'd modified your
498-
program, Cargo would have built the file before running it, and you would have
499-
seen something like this:
493+
the file hasn’t changed, and so it just ran the binary. If you'd modified your
494+
source code, Cargo would have rebuilt the project before running it, and you
495+
would have seen something like this:
500496

501497
```bash
502498
$ cargo run
@@ -509,9 +505,9 @@ Cargo checks to see if any of your project’s files have been modified, and onl
509505
rebuilds your project if they’ve changed since the last time you built it.
510506

511507
With simple projects, Cargo doesn't bring a whole lot over just using `rustc`,
512-
but it will become useful in future. When your projects get more complex,
513-
you'll need to do more things to get all of the parts to properly compile. With
514-
Cargo, you can just run `cargo build`, and it should work the right way.
508+
but it will become useful in future. With complex projects composed of multiple
509+
crates, it’s much easier to let Cargo coordinate the build. With Cargo, you can
510+
just run `cargo build`, and it should work the right way.
515511

516512
## Building for Release
517513

0 commit comments

Comments
 (0)