Skip to content

Commit 20b3313

Browse files
committed
auto merge of #16471 : EduardoBautista/rust/chapter-14-fixes, r=steveklabnik
Just some small fixes for the guide. The cargo stuff is probably because of an update.
2 parents e052aa6 + 48c0f59 commit 20b3313

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

src/doc/guide.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Once you have this file in place, we should be ready to build! Try this:
342342

343343
```{bash}
344344
$ cargo build
345-
Compiling hello_world v0.1.0 (file:/home/yourname/projects/hello_world)
345+
Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world)
346346
$ ./target/hello_world
347347
Hello, world!
348348
```
@@ -486,7 +486,7 @@ You can use `cargo build` on the command line to build it. You'll get a warning,
486486
but it will still print "Hello, world!":
487487

488488
```{ignore,notrust}
489-
Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world)
489+
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
490490
src/hello_world.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
491491
src/hello_world.rs:2 let x: int;
492492
^
@@ -508,7 +508,7 @@ And try to build it. You'll get an error:
508508

509509
```{bash}
510510
$ cargo build
511-
Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world)
511+
Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world)
512512
src/hello_world.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
513513
src/hello_world.rs:4 println!("The value of x is: {}", x);
514514
^
@@ -1782,7 +1782,7 @@ Check out the generated `Cargo.toml`:
17821782
[package]
17831783
17841784
name = "guessing_game"
1785-
version = "0.1.0"
1785+
version = "0.0.1"
17861786
authors = ["Your Name <you@example.com>"]
17871787
```
17881788

@@ -1793,15 +1793,15 @@ Finally, Cargo generated a hello, world for us. Check out `src/main.rs`:
17931793

17941794
```{rust}
17951795
fn main() {
1796-
println!("Hello world!");
1796+
println!("Hello, world!");
17971797
}
17981798
```
17991799

18001800
Let's try compiling what Cargo gave us:
18011801

18021802
```{bash}
18031803
$ cargo build
1804-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1804+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
18051805
$
18061806
```
18071807

@@ -1914,7 +1914,7 @@ Let's try to compile this using `cargo build`:
19141914

19151915
```{notrust,no_run}
19161916
$ cargo build
1917-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1917+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
19181918
src/main.rs:7:26: 7:34 error: the type of this value must be known in this context
19191919
src/main.rs:7 let secret_number = (rand::random() % 100i) + 1i;
19201920
^~~~~~~~
@@ -1962,7 +1962,7 @@ fn main() {
19621962

19631963
```{notrust,ignore}
19641964
$ cargo build
1965-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
1965+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
19661966
$
19671967
```
19681968

@@ -2021,8 +2021,8 @@ And trying it out:
20212021

20222022
```{notrust,ignore}
20232023
$ cargo build
2024-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2025-
$ ./target/guessing_game
2024+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2025+
$ ./target/guessing_game
20262026
Guess the number!
20272027
The secret number is: 57
20282028
Please input your guess.
@@ -2076,7 +2076,7 @@ If we try to compile, we'll get some errors:
20762076

20772077
```{notrust,ignore}
20782078
$ cargo build
2079-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2079+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
20802080
src/main.rs:20:15: 20:20 error: mismatched types: expected `int` but found `collections::string::String` (expected int but found struct collections::string::String)
20812081
src/main.rs:20 match cmp(input, secret_number) {
20822082
^~~~~
@@ -2130,7 +2130,7 @@ And try compiling again:
21302130

21312131
```{notrust,ignore}
21322132
$ cargo build
2133-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2133+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
21342134
src/main.rs:20:15: 20:20 error: mismatched types: expected `uint` but found `collections::string::String` (expected uint but found struct collections::string::String)
21352135
src/main.rs:20 match cmp(input, secret_number) {
21362136
^~~~~
@@ -2161,7 +2161,7 @@ a function for that:
21612161
let input = io::stdin().read_line()
21622162
.ok()
21632163
.expect("Failed to read line");
2164-
let guess: Option<uint> = from_str(input.as_slice());
2164+
let input_num: Option<uint> = from_str(input.as_slice());
21652165
```
21662166

21672167
The `from_str` function takes in a `&str` value and converts it into something.
@@ -2183,8 +2183,8 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly
21832183
tell `random()` what to generate. In a similar fashion, both of these work:
21842184

21852185
```{rust,ignore}
2186-
let guess = from_str::<Option<uint>>("5");
2187-
let guess: Option<uint> = from_str("5");
2186+
let input_num = from_str::<Option<uint>>("5");
2187+
let input_num: Option<uint> = from_str("5");
21882188
```
21892189

21902190
In this case, I happen to prefer the latter, and in the `random()` case, I prefer
@@ -2233,7 +2233,7 @@ Let's try it out!
22332233

22342234
```{notrust,ignore}
22352235
$ cargo build
2236-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2236+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
22372237
src/main.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option<uint>` (expected uint but found enum core::option::Option)
22382238
src/main.rs:22 match cmp(input_num, secret_number) {
22392239
^~~~~~~~~
@@ -2292,8 +2292,8 @@ print an error message and return. Let's give this a shot:
22922292

22932293
```{notrust,ignore}
22942294
$ cargo build
2295-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2296-
$ ./target/guessing_game
2295+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2296+
$ ./target/guessing_game
22972297
Guess the number!
22982298
The secret number is: 17
22992299
Please input your guess.
@@ -2358,8 +2358,8 @@ Let's try it!
23582358

23592359
```{notrust,ignore}
23602360
$ cargo build
2361-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2362-
$ ./target/guessing_game
2361+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2362+
$ ./target/guessing_game
23632363
Guess the number!
23642364
The secret number is: 58
23652365
Please input your guess.
@@ -2436,8 +2436,8 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe:
24362436

24372437
```{notrust,ignore}
24382438
$ cargo build
2439-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2440-
$ ./target/guessing_game
2439+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2440+
$ ./target/guessing_game
24412441
Guess the number!
24422442
The secret number is: 59
24432443
Please input your guess.
@@ -2569,8 +2569,8 @@ Now we should be good! Let's try:
25692569

25702570
```{rust,ignore}
25712571
$ cargo build
2572-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2573-
$ ./target/guessing_game
2572+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
2573+
$ ./target/guessing_game
25742574
Guess the number!
25752575
The secret number is: 61
25762576
Please input your guess.
@@ -2684,7 +2684,7 @@ Let's double check our work by compiling:
26842684

26852685
```{bash,ignore}
26862686
$ cargo build
2687-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2687+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
26882688
$ ./target/modules
26892689
Hello, world!
26902690
```
@@ -2745,7 +2745,7 @@ mod hello {
27452745
It gives an error:
27462746

27472747
```{notrust,ignore}
2748-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2748+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
27492749
src/main.rs:2:5: 2:23 error: function `print_hello` is private
27502750
src/main.rs:2 hello::print_hello();
27512751
^~~~~~~~~~~~~~~~~~
@@ -2769,7 +2769,7 @@ This will work:
27692769

27702770
```{notrust,ignore}
27712771
$ cargo run
2772-
Compiling modules v0.1.0 (file:/home/steve/tmp/modules)
2772+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
27732773
Running `target/modules`
27742774
Hello, world!
27752775
$
@@ -2819,7 +2819,7 @@ This doesn't _quite_ work yet. Try it:
28192819

28202820
```{notrust,ignore}
28212821
$ cargo build
2822-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2822+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
28232823
/home/you/projects/modules/src/lib.rs:2:5: 4:6 warning: code is never used: `print_hello`, #[warn(dead_code)] on by default
28242824
/home/you/projects/modules/src/lib.rs:2 pub fn print_hello() {
28252825
/home/you/projects/modules/src/lib.rs:3 println!("Hello, world!");
@@ -2855,7 +2855,7 @@ And everything should work:
28552855

28562856
```{notrust,ignore}
28572857
$ cargo run
2858-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2858+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
28592859
Running `target/modules`
28602860
Hello, world!
28612861
```
@@ -2921,7 +2921,7 @@ This should all compile as usual:
29212921

29222922
```{notrust,ignore}
29232923
$ cargo build
2924-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2924+
Compiling modules v0.0.1 (file:///home/you/projects/modules)
29252925
$
29262926
```
29272927

@@ -3093,7 +3093,7 @@ And try it out:
30933093

30943094
```{notrust,ignore}
30953095
$ cargo run
3096-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3096+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
30973097
Running `target/testing`
30983098
Hello, world!
30993099
$
@@ -3126,7 +3126,7 @@ it `false`, so this test should fail. Let's try it!
31263126

31273127
```{notrust,ignore}
31283128
$ cargo test
3129-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3129+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
31303130
/home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default
31313131
/home/you/projects/testing/src/main.rs:1 fn main() {
31323132
/home/you/projects/testing/src/main.rs:2 println!("Hello, world");
@@ -3159,7 +3159,7 @@ Lots of output! Let's break this down:
31593159

31603160
```{notrust,ignore}
31613161
$ cargo test
3162-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3162+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
31633163
```
31643164

31653165
You can run all of your tests with `cargo test`. This runs both your tests in
@@ -3234,7 +3234,7 @@ And then try to run our tests again:
32343234

32353235
```{notrust,ignore}
32363236
$ cargo test
3237-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3237+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
32383238
/home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default
32393239
/home/you/projects/testing/src/main.rs:1 fn main() {
32403240
/home/you/projects/testing/src/main.rs:2 println!("Hello, world");
@@ -3273,7 +3273,7 @@ With this attribute, we won't get the warning:
32733273

32743274
```{notrust,ignore}
32753275
$ cargo test
3276-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3276+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
32773277
32783278
running 0 tests
32793279
@@ -3302,7 +3302,7 @@ And try to run the test:
33023302

33033303
```{notrust,ignore}
33043304
$ cargo test
3305-
Compiling testing v0.1.0 (file:/home/youg/projects/testing)
3305+
Compiling testing v0.0.1 (file:///home/youg/projects/testing)
33063306
/home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
33073307
/home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
33083308
^~~~~~~~~~~~~~~~~~~~
@@ -3361,7 +3361,7 @@ Let's give it a run:
33613361

33623362
```{ignore,notrust}
33633363
$ cargo test
3364-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3364+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
33653365
33663366
running 0 tests
33673367
@@ -3401,7 +3401,7 @@ If you run `cargo test`, you should get the same output:
34013401

34023402
```{ignore,notrust}
34033403
$ cargo test
3404-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3404+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
34053405
34063406
running 0 tests
34073407
@@ -3445,7 +3445,7 @@ fn test_add_three() {
34453445
We'd get this error:
34463446

34473447
```{notrust,ignore}
3448-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3448+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
34493449
/home/you/projects/testing/tests/lib.rs:3:5: 3:24 error: function `add_three` is private
34503450
/home/you/projects/testing/tests/lib.rs:3 use testing::add_three;
34513451
^~~~~~~~~~~~~~~~~~~
@@ -3488,7 +3488,7 @@ Let's give it a shot:
34883488

34893489
```{ignore,notrust}
34903490
$ cargo test
3491-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3491+
Compiling testing v0.0.1 (file:///home/you/projects/testing)
34923492
34933493
running 1 test
34943494
test test::test_times_four ... ok

0 commit comments

Comments
 (0)