From 63e99f999de3e39bc958366a8abcbec0218eecc3 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Sat, 9 Aug 2014 22:45:18 -0500 Subject: [PATCH 1/6] Cargo begins version number at 0.0.1 instead of 0.1.0 --- src/doc/guide.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 94c77efc94d97..b78272632e89a 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -1769,7 +1769,7 @@ Check out the generated `Cargo.toml`: [package] name = "guessing_game" -version = "0.1.0" +version = "0.0.1" authors = ["Your Name "] ``` @@ -1788,7 +1788,7 @@ Let's try compiling what Cargo gave us: ```{bash} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) $ ``` @@ -1901,7 +1901,7 @@ Let's try to compile this using `cargo build`: ```{notrust,no_run} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) src/main.rs:7:26: 7:34 error: the type of this value must be known in this context src/main.rs:7 let secret_number = (rand::random() % 100i) + 1i; ^~~~~~~~ @@ -1949,7 +1949,7 @@ fn main() { ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) $ ``` @@ -2008,8 +2008,8 @@ And trying it out: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) -$ ./target/guessing_game + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) +$ ./target/guessing_game Guess the number! The secret number is: 57 Please input your guess. @@ -2063,7 +2063,7 @@ If we try to compile, we'll get some errors: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) 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) src/main.rs:20 match cmp(input, secret_number) { ^~~~~ @@ -2117,7 +2117,7 @@ And try compiling again: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) 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) src/main.rs:20 match cmp(input, secret_number) { ^~~~~ @@ -2220,7 +2220,7 @@ Let's try it out! ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) src/main.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option` (expected uint but found enum core::option::Option) src/main.rs:22 match cmp(input_num, secret_number) { ^~~~~~~~~ @@ -2345,8 +2345,8 @@ Let's try it! ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) -$ ./target/guessing_game + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) +$ ./target/guessing_game Guess the number! The secret number is: 58 Please input your guess. @@ -2423,8 +2423,8 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) -$ ./target/guessing_game + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) +$ ./target/guessing_game Guess the number! The secret number is: 59 Please input your guess. @@ -2556,8 +2556,8 @@ Now we should be good! Let's try: ```{rust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) -$ ./target/guessing_game + Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) +$ ./target/guessing_game Guess the number! The secret number is: 61 Please input your guess. From 7ebb392fa9d8ead6b4680cbcc4eca5ad79732901 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Sat, 9 Aug 2014 22:47:28 -0500 Subject: [PATCH 2/6] Cargo generates "Hello, world!" instead of "Hello world!" --- src/doc/guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index b78272632e89a..033e6184d25c1 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -1780,7 +1780,7 @@ Finally, Cargo generated a hello, world for us. Check out `src/main.rs`: ```{rust} fn main() { - println!("Hello world!"); + println!("Hello, world!"); } ``` From 6d189220d19f32e1c0ebc4395cad58a2708fc574 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Wed, 13 Aug 2014 01:04:32 -0500 Subject: [PATCH 3/6] `input_num` is used is used instead of `guess` further in the guide --- src/doc/guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 033e6184d25c1..5730be093a9e7 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -2148,7 +2148,7 @@ a function for that: let input = io::stdin().read_line() .ok() .expect("Failed to read line"); -let guess: Option = from_str(input.as_slice()); +let input_num: Option = from_str(input.as_slice()); ``` The `from_str` function takes in a `&str` value and converts it into something. @@ -2170,8 +2170,8 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly tell `random()` what to generate. In a similar fashion, both of these work: ```{rust,ignore} -let guess = from_str::>("5"); -let guess: Option = from_str("5"); +let input_num = from_str::>("5"); +let input_num: Option = from_str("5"); ``` In this case, I happen to prefer the latter, and in the `random()` case, I prefer From c9284cedeb7ff4ff3d133b37bad8b1d6c32329d3 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Wed, 13 Aug 2014 17:25:13 -0500 Subject: [PATCH 4/6] Use new Cargo file syntax --- src/doc/guide.md | 72 +++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 5730be093a9e7..8e942e534c3e4 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -342,7 +342,7 @@ Once you have this file in place, we should be ready to build! Try this: ```{bash} $ cargo build - Compiling hello_world v0.1.0 (file:/home/yourname/projects/hello_world) + Compiling hello_world v0.1.0 (file:///home/yourname/projects/hello_world) $ ./target/hello_world Hello, world! ``` @@ -486,7 +486,7 @@ You can use `cargo build` on the command line to build it. You'll get a warning, but it will still print "Hello, world!": ```{ignore,notrust} - Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world) + Compiling hello_world v0.1.0 (file:///home/you/projects/hello_world) src/hello_world.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default src/hello_world.rs:2 let x: int; ^ @@ -508,7 +508,7 @@ And try to build it. You'll get an error: ```{bash} $ cargo build - Compiling hello_world v0.1.0 (file:/home/you/projects/hello_world) + Compiling hello_world v0.1.0 (file:///home/you/projects/hello_world) src/hello_world.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x` src/hello_world.rs:4 println!("The value of x is: {}", x); ^ @@ -1788,7 +1788,7 @@ Let's try compiling what Cargo gave us: ```{bash} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ``` @@ -1901,7 +1901,7 @@ Let's try to compile this using `cargo build`: ```{notrust,no_run} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:7:26: 7:34 error: the type of this value must be known in this context src/main.rs:7 let secret_number = (rand::random() % 100i) + 1i; ^~~~~~~~ @@ -1949,7 +1949,7 @@ fn main() { ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ``` @@ -2008,7 +2008,7 @@ And trying it out: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ./target/guessing_game Guess the number! The secret number is: 57 @@ -2063,7 +2063,7 @@ If we try to compile, we'll get some errors: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) 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) src/main.rs:20 match cmp(input, secret_number) { ^~~~~ @@ -2117,7 +2117,7 @@ And try compiling again: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) 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) src/main.rs:20 match cmp(input, secret_number) { ^~~~~ @@ -2220,7 +2220,7 @@ Let's try it out! ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) src/main.rs:22:15: 22:24 error: mismatched types: expected `uint` but found `core::option::Option` (expected uint but found enum core::option::Option) src/main.rs:22 match cmp(input_num, secret_number) { ^~~~~~~~~ @@ -2279,8 +2279,8 @@ print an error message and return. Let's give this a shot: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game) -$ ./target/guessing_game + Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) +$ ./target/guessing_game Guess the number! The secret number is: 17 Please input your guess. @@ -2345,7 +2345,7 @@ Let's try it! ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ./target/guessing_game Guess the number! The secret number is: 58 @@ -2423,7 +2423,7 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ./target/guessing_game Guess the number! The secret number is: 59 @@ -2556,7 +2556,7 @@ Now we should be good! Let's try: ```{rust,ignore} $ cargo build - Compiling guessing_game v0.0.1 (file:/home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ./target/guessing_game Guess the number! The secret number is: 61 @@ -2671,7 +2671,7 @@ Let's double check our work by compiling: ```{bash,ignore} $ cargo build - Compiling modules v0.1.0 (file:/home/you/projects/modules) + Compiling modules v0.1.0 (file:///home/you/projects/modules) $ ./target/modules Hello, world! ``` @@ -2732,7 +2732,7 @@ mod hello { It gives an error: ```{notrust,ignore} - Compiling modules v0.1.0 (file:/home/you/projects/modules) + Compiling modules v0.1.0 (file:///home/you/projects/modules) src/main.rs:2:5: 2:23 error: function `print_hello` is private src/main.rs:2 hello::print_hello(); ^~~~~~~~~~~~~~~~~~ @@ -2754,9 +2754,19 @@ mod hello { This will work: +```{notrust,ignore} +$ cargo build + Compiling modules v0.1.0 (file:///home/you/projects/modules) +$ +``` + +Before we move on, let me show you one more Cargo command: `run`. `cargo run` +is kind of like `cargo build`, but it also then runs the produced exectuable. +Try it out: + ```{notrust,ignore} $ cargo run - Compiling modules v0.1.0 (file:/home/steve/tmp/modules) + Compiling modules v0.1.0 (file:///home/steve/tmp/modules) Running `target/modules` Hello, world! $ @@ -2806,7 +2816,7 @@ This doesn't _quite_ work yet. Try it: ```{notrust,ignore} $ cargo build - Compiling modules v0.1.0 (file:/home/you/projects/modules) + Compiling modules v0.1.0 (file:///home/you/projects/modules) /home/you/projects/modules/src/lib.rs:2:5: 4:6 warning: code is never used: `print_hello`, #[warn(dead_code)] on by default /home/you/projects/modules/src/lib.rs:2 pub fn print_hello() { /home/you/projects/modules/src/lib.rs:3 println!("Hello, world!"); @@ -2842,7 +2852,7 @@ And everything should work: ```{notrust,ignore} $ cargo run - Compiling modules v0.1.0 (file:/home/you/projects/modules) + Compiling modules v0.1.0 (file:///home/you/projects/modules) Running `target/modules` Hello, world! ``` @@ -2908,7 +2918,7 @@ This should all compile as usual: ```{notrust,ignore} $ cargo build - Compiling modules v0.1.0 (file:/home/you/projects/modules) + Compiling modules v0.1.0 (file:///home/you/projects/modules) $ ``` @@ -3080,7 +3090,7 @@ And try it out: ```{notrust,ignore} $ cargo run - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) Running `target/testing` Hello, world! $ @@ -3113,7 +3123,7 @@ it `false`, so this test should fail. Let's try it! ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default /home/you/projects/testing/src/main.rs:1 fn main() { /home/you/projects/testing/src/main.rs:2 println!("Hello, world"); @@ -3146,7 +3156,7 @@ Lots of output! Let's break this down: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) ``` 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: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default /home/you/projects/testing/src/main.rs:1 fn main() { /home/you/projects/testing/src/main.rs:2 println!("Hello, world"); @@ -3260,7 +3270,7 @@ With this attribute, we won't get the warning: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) running 0 tests @@ -3289,7 +3299,7 @@ And try to run the test: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:/home/youg/projects/testing) + Compiling testing v0.1.0 (file:///home/youg/projects/testing) /home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`. /home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i); ^~~~~~~~~~~~~~~~~~~~ @@ -3348,7 +3358,7 @@ Let's give it a run: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) running 0 tests @@ -3388,7 +3398,7 @@ If you run `cargo test`, you should get the same output: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) running 0 tests @@ -3432,7 +3442,7 @@ fn test_add_three() { We'd get this error: ```{notrust,ignore} - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) /home/you/projects/testing/tests/lib.rs:3:5: 3:24 error: function `add_three` is private /home/you/projects/testing/tests/lib.rs:3 use testing::add_three; ^~~~~~~~~~~~~~~~~~~ @@ -3475,7 +3485,7 @@ Let's give it a shot: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:/home/you/projects/testing) + Compiling testing v0.1.0 (file:///home/you/projects/testing) running 1 test test test::test_times_four ... ok From 6b26aaea3e01f54eea8f4c1238a6bf9ede1574aa Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Wed, 13 Aug 2014 17:26:49 -0500 Subject: [PATCH 5/6] Use new Cargo starting version number --- src/doc/guide.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 8e942e534c3e4..56a48d5630203 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -342,7 +342,7 @@ Once you have this file in place, we should be ready to build! Try this: ```{bash} $ cargo build - Compiling hello_world v0.1.0 (file:///home/yourname/projects/hello_world) + Compiling hello_world v0.0.1 (file:///home/yourname/projects/hello_world) $ ./target/hello_world Hello, world! ``` @@ -486,7 +486,7 @@ You can use `cargo build` on the command line to build it. You'll get a warning, but it will still print "Hello, world!": ```{ignore,notrust} - Compiling hello_world v0.1.0 (file:///home/you/projects/hello_world) + Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) src/hello_world.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default src/hello_world.rs:2 let x: int; ^ @@ -508,7 +508,7 @@ And try to build it. You'll get an error: ```{bash} $ cargo build - Compiling hello_world v0.1.0 (file:///home/you/projects/hello_world) + Compiling hello_world v0.0.1 (file:///home/you/projects/hello_world) src/hello_world.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x` src/hello_world.rs:4 println!("The value of x is: {}", x); ^ @@ -2279,7 +2279,7 @@ print an error message and return. Let's give this a shot: ```{notrust,ignore} $ cargo build - Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game) + Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game) $ ./target/guessing_game Guess the number! The secret number is: 17 @@ -2671,7 +2671,7 @@ Let's double check our work by compiling: ```{bash,ignore} $ cargo build - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) $ ./target/modules Hello, world! ``` @@ -2732,7 +2732,7 @@ mod hello { It gives an error: ```{notrust,ignore} - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) src/main.rs:2:5: 2:23 error: function `print_hello` is private src/main.rs:2 hello::print_hello(); ^~~~~~~~~~~~~~~~~~ @@ -2756,7 +2756,7 @@ This will work: ```{notrust,ignore} $ cargo build - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) $ ``` @@ -2766,7 +2766,7 @@ Try it out: ```{notrust,ignore} $ cargo run - Compiling modules v0.1.0 (file:///home/steve/tmp/modules) + Compiling modules v0.0.1 (file:///home/steve/tmp/modules) Running `target/modules` Hello, world! $ @@ -2816,7 +2816,7 @@ This doesn't _quite_ work yet. Try it: ```{notrust,ignore} $ cargo build - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) /home/you/projects/modules/src/lib.rs:2:5: 4:6 warning: code is never used: `print_hello`, #[warn(dead_code)] on by default /home/you/projects/modules/src/lib.rs:2 pub fn print_hello() { /home/you/projects/modules/src/lib.rs:3 println!("Hello, world!"); @@ -2852,7 +2852,7 @@ And everything should work: ```{notrust,ignore} $ cargo run - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) Running `target/modules` Hello, world! ``` @@ -2918,7 +2918,7 @@ This should all compile as usual: ```{notrust,ignore} $ cargo build - Compiling modules v0.1.0 (file:///home/you/projects/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) $ ``` @@ -3090,7 +3090,7 @@ And try it out: ```{notrust,ignore} $ cargo run - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) Running `target/testing` Hello, world! $ @@ -3123,7 +3123,7 @@ it `false`, so this test should fail. Let's try it! ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default /home/you/projects/testing/src/main.rs:1 fn main() { /home/you/projects/testing/src/main.rs:2 println!("Hello, world"); @@ -3156,7 +3156,7 @@ Lots of output! Let's break this down: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) ``` You can run all of your tests with `cargo test`. This runs both your tests in @@ -3231,7 +3231,7 @@ And then try to run our tests again: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/src/main.rs:1:1: 3:2 warning: code is never used: `main`, #[warn(dead_code)] on by default /home/you/projects/testing/src/main.rs:1 fn main() { /home/you/projects/testing/src/main.rs:2 println!("Hello, world"); @@ -3270,7 +3270,7 @@ With this attribute, we won't get the warning: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) running 0 tests @@ -3299,7 +3299,7 @@ And try to run the test: ```{notrust,ignore} $ cargo test - Compiling testing v0.1.0 (file:///home/youg/projects/testing) + Compiling testing v0.0.1 (file:///home/youg/projects/testing) /home/youg/projects/testing/tests/lib.rs:3:18: 3:38 error: unresolved name `add_three_times_four`. /home/youg/projects/testing/tests/lib.rs:3 let result = add_three_times_four(5i); ^~~~~~~~~~~~~~~~~~~~ @@ -3358,7 +3358,7 @@ Let's give it a run: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) running 0 tests @@ -3398,7 +3398,7 @@ If you run `cargo test`, you should get the same output: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) running 0 tests @@ -3442,7 +3442,7 @@ fn test_add_three() { We'd get this error: ```{notrust,ignore} - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) /home/you/projects/testing/tests/lib.rs:3:5: 3:24 error: function `add_three` is private /home/you/projects/testing/tests/lib.rs:3 use testing::add_three; ^~~~~~~~~~~~~~~~~~~ @@ -3485,7 +3485,7 @@ Let's give it a shot: ```{ignore,notrust} $ cargo test - Compiling testing v0.1.0 (file:///home/you/projects/testing) + Compiling testing v0.0.1 (file:///home/you/projects/testing) running 1 test test test::test_times_four ... ok From 48c0f596a70bb69ab05f4e34c78db910cf962e05 Mon Sep 17 00:00:00 2001 From: Eduardo Bautista Date: Tue, 19 Aug 2014 00:19:22 -0700 Subject: [PATCH 6/6] Remove repeated section and make file path generic --- src/doc/guide.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 56a48d5630203..42b929e39950e 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -2754,19 +2754,9 @@ mod hello { This will work: -```{notrust,ignore} -$ cargo build - Compiling modules v0.0.1 (file:///home/you/projects/modules) -$ -``` - -Before we move on, let me show you one more Cargo command: `run`. `cargo run` -is kind of like `cargo build`, but it also then runs the produced exectuable. -Try it out: - ```{notrust,ignore} $ cargo run - Compiling modules v0.0.1 (file:///home/steve/tmp/modules) + Compiling modules v0.0.1 (file:///home/you/projects/modules) Running `target/modules` Hello, world! $