Skip to content

Commit 042f6ba

Browse files
---
yaml --- r: 128976 b: refs/heads/try c: c9284ce h: refs/heads/master v: v3
1 parent 45782a6 commit 042f6ba

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: 6d189220d19f32e1c0ebc4395cad58a2708fc574
5+
refs/heads/try: c9284cedeb7ff4ff3d133b37bad8b1d6c32329d3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide.md

Lines changed: 41 additions & 31 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.1.0 (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.1.0 (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.1.0 (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
^
@@ -1788,7 +1788,7 @@ Let's try compiling what Cargo gave us:
17881788

17891789
```{bash}
17901790
$ cargo build
1791-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
1791+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
17921792
$
17931793
```
17941794

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

19021902
```{notrust,no_run}
19031903
$ cargo build
1904-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
1904+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
19051905
src/main.rs:7:26: 7:34 error: the type of this value must be known in this context
19061906
src/main.rs:7 let secret_number = (rand::random() % 100i) + 1i;
19071907
^~~~~~~~
@@ -1949,7 +1949,7 @@ fn main() {
19491949

19501950
```{notrust,ignore}
19511951
$ cargo build
1952-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
1952+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
19531953
$
19541954
```
19551955

@@ -2008,7 +2008,7 @@ And trying it out:
20082008

20092009
```{notrust,ignore}
20102010
$ cargo build
2011-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2011+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
20122012
$ ./target/guessing_game
20132013
Guess the number!
20142014
The secret number is: 57
@@ -2063,7 +2063,7 @@ If we try to compile, we'll get some errors:
20632063

20642064
```{notrust,ignore}
20652065
$ cargo build
2066-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2066+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
20672067
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)
20682068
src/main.rs:20 match cmp(input, secret_number) {
20692069
^~~~~
@@ -2117,7 +2117,7 @@ And try compiling again:
21172117

21182118
```{notrust,ignore}
21192119
$ cargo build
2120-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2120+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
21212121
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)
21222122
src/main.rs:20 match cmp(input, secret_number) {
21232123
^~~~~
@@ -2220,7 +2220,7 @@ Let's try it out!
22202220

22212221
```{notrust,ignore}
22222222
$ cargo build
2223-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2223+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
22242224
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)
22252225
src/main.rs:22 match cmp(input_num, secret_number) {
22262226
^~~~~~~~~
@@ -2279,8 +2279,8 @@ print an error message and return. Let's give this a shot:
22792279

22802280
```{notrust,ignore}
22812281
$ cargo build
2282-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
2283-
$ ./target/guessing_game
2282+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2283+
$ ./target/guessing_game
22842284
Guess the number!
22852285
The secret number is: 17
22862286
Please input your guess.
@@ -2345,7 +2345,7 @@ Let's try it!
23452345

23462346
```{notrust,ignore}
23472347
$ cargo build
2348-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2348+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
23492349
$ ./target/guessing_game
23502350
Guess the number!
23512351
The secret number is: 58
@@ -2423,7 +2423,7 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe:
24232423

24242424
```{notrust,ignore}
24252425
$ cargo build
2426-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2426+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
24272427
$ ./target/guessing_game
24282428
Guess the number!
24292429
The secret number is: 59
@@ -2556,7 +2556,7 @@ Now we should be good! Let's try:
25562556

25572557
```{rust,ignore}
25582558
$ cargo build
2559-
Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game)
2559+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
25602560
$ ./target/guessing_game
25612561
Guess the number!
25622562
The secret number is: 61
@@ -2671,7 +2671,7 @@ Let's double check our work by compiling:
26712671

26722672
```{bash,ignore}
26732673
$ cargo build
2674-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2674+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
26752675
$ ./target/modules
26762676
Hello, world!
26772677
```
@@ -2732,7 +2732,7 @@ mod hello {
27322732
It gives an error:
27332733

27342734
```{notrust,ignore}
2735-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2735+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
27362736
src/main.rs:2:5: 2:23 error: function `print_hello` is private
27372737
src/main.rs:2 hello::print_hello();
27382738
^~~~~~~~~~~~~~~~~~
@@ -2754,9 +2754,19 @@ mod hello {
27542754

27552755
This will work:
27562756

2757+
```{notrust,ignore}
2758+
$ cargo build
2759+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
2760+
$
2761+
```
2762+
2763+
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
2764+
is kind of like `cargo build`, but it also then runs the produced exectuable.
2765+
Try it out:
2766+
27572767
```{notrust,ignore}
27582768
$ cargo run
2759-
Compiling modules v0.1.0 (file:/home/steve/tmp/modules)
2769+
Compiling modules v0.1.0 (file:///home/steve/tmp/modules)
27602770
Running `target/modules`
27612771
Hello, world!
27622772
$
@@ -2806,7 +2816,7 @@ This doesn't _quite_ work yet. Try it:
28062816

28072817
```{notrust,ignore}
28082818
$ cargo build
2809-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2819+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
28102820
/home/you/projects/modules/src/lib.rs:2:5: 4:6 warning: code is never used: `print_hello`, #[warn(dead_code)] on by default
28112821
/home/you/projects/modules/src/lib.rs:2 pub fn print_hello() {
28122822
/home/you/projects/modules/src/lib.rs:3 println!("Hello, world!");
@@ -2842,7 +2852,7 @@ And everything should work:
28422852

28432853
```{notrust,ignore}
28442854
$ cargo run
2845-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2855+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
28462856
Running `target/modules`
28472857
Hello, world!
28482858
```
@@ -2908,7 +2918,7 @@ This should all compile as usual:
29082918

29092919
```{notrust,ignore}
29102920
$ cargo build
2911-
Compiling modules v0.1.0 (file:/home/you/projects/modules)
2921+
Compiling modules v0.1.0 (file:///home/you/projects/modules)
29122922
$
29132923
```
29142924

@@ -3080,7 +3090,7 @@ And try it out:
30803090

30813091
```{notrust,ignore}
30823092
$ cargo run
3083-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3093+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
30843094
Running `target/testing`
30853095
Hello, world!
30863096
$
@@ -3113,7 +3123,7 @@ it `false`, so this test should fail. Let's try it!
31133123

31143124
```{notrust,ignore}
31153125
$ cargo test
3116-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3126+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
31173127
/home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default
31183128
/home/you/projects/testing/src/main.rs:1 fn main() {
31193129
/home/you/projects/testing/src/main.rs:2 println!("Hello, world");
@@ -3146,7 +3156,7 @@ Lots of output! Let's break this down:
31463156

31473157
```{notrust,ignore}
31483158
$ cargo test
3149-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3159+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
31503160
```
31513161

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

32223232
```{notrust,ignore}
32233233
$ cargo test
3224-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3234+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
32253235
/home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default
32263236
/home/you/projects/testing/src/main.rs:1 fn main() {
32273237
/home/you/projects/testing/src/main.rs:2 println!("Hello, world");
@@ -3260,7 +3270,7 @@ With this attribute, we won't get the warning:
32603270

32613271
```{notrust,ignore}
32623272
$ cargo test
3263-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3273+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
32643274
32653275
running 0 tests
32663276
@@ -3289,7 +3299,7 @@ And try to run the test:
32893299

32903300
```{notrust,ignore}
32913301
$ cargo test
3292-
Compiling testing v0.1.0 (file:/home/youg/projects/testing)
3302+
Compiling testing v0.1.0 (file:///home/youg/projects/testing)
32933303
/home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`.
32943304
/home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i);
32953305
^~~~~~~~~~~~~~~~~~~~
@@ -3348,7 +3358,7 @@ Let's give it a run:
33483358

33493359
```{ignore,notrust}
33503360
$ cargo test
3351-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3361+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
33523362
33533363
running 0 tests
33543364
@@ -3388,7 +3398,7 @@ If you run `cargo test`, you should get the same output:
33883398

33893399
```{ignore,notrust}
33903400
$ cargo test
3391-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3401+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
33923402
33933403
running 0 tests
33943404
@@ -3432,7 +3442,7 @@ fn test_add_three() {
34323442
We'd get this error:
34333443

34343444
```{notrust,ignore}
3435-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3445+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
34363446
/home/you/projects/testing/tests/lib.rs:3:5: 3:24 error: function `add_three` is private
34373447
/home/you/projects/testing/tests/lib.rs:3 use testing::add_three;
34383448
^~~~~~~~~~~~~~~~~~~
@@ -3475,7 +3485,7 @@ Let's give it a shot:
34753485

34763486
```{ignore,notrust}
34773487
$ cargo test
3478-
Compiling testing v0.1.0 (file:/home/you/projects/testing)
3488+
Compiling testing v0.1.0 (file:///home/you/projects/testing)
34793489
34803490
running 1 test
34813491
test test::test_times_four ... ok

0 commit comments

Comments
 (0)