diff --git a/src/attribute/cfg/custom.md b/src/attribute/cfg/custom.md index 90b2a0ee2f..182d33654c 100644 --- a/src/attribute/cfg/custom.md +++ b/src/attribute/cfg/custom.md @@ -18,7 +18,7 @@ Try to run this to see what happens without the custom `cfg` flag. With the custom `cfg` flag: -```bash +```shell $ rustc --cfg some_condition custom.rs && ./custom condition met! ``` diff --git a/src/attribute/crate.md b/src/attribute/crate.md index 33674faaec..1539c63988 100644 --- a/src/attribute/crate.md +++ b/src/attribute/crate.md @@ -33,7 +33,7 @@ pub fn indirect_access() { When the `crate_type` attribute is used, we no longer need to pass the `--crate-type` flag to `rustc`. -```bash +```shell $ rustc lib.rs $ ls lib* library.rlib diff --git a/src/cargo/test.md b/src/cargo/test.md index b5ace3c6f9..b4bc69d5c5 100644 --- a/src/cargo/test.md +++ b/src/cargo/test.md @@ -23,13 +23,13 @@ Each file in `tests` is a separate integration test. `cargo` naturally provides an easy way to run all of your tests! -```sh -cargo test +```shell +$ cargo test ``` You should see output like this: -```txt +```shell $ cargo test Compiling blah v0.1.0 (file:///nobackup/blah) Finished dev [unoptimized + debuginfo] target(s) in 0.89 secs @@ -46,11 +46,11 @@ test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out You can also run tests whose name matches a pattern: -```sh -cargo test test_foo +```shell +$ cargo test test_foo ``` -```txt +```shell $ cargo test test_foo Compiling blah v0.1.0 (file:///nobackup/blah) Finished dev [unoptimized + debuginfo] target(s) in 0.35 secs diff --git a/src/crates/lib.md b/src/crates/lib.md index f20fe5990e..92eddc6ac6 100644 --- a/src/crates/lib.md +++ b/src/crates/lib.md @@ -18,7 +18,7 @@ pub fn indirect_access() { } ``` -```bash +```shell $ rustc --crate-type=lib rary.rs $ ls lib* library.rlib diff --git a/src/crates/link.md b/src/crates/link.md index 6bd17ae988..828fbdbeba 100644 --- a/src/crates/link.md +++ b/src/crates/link.md @@ -19,7 +19,7 @@ fn main() { } ``` -```bash +```txt # Where library.rlib is the path to the compiled library, assumed that it's # in the same directory here: $ rustc executable.rs --extern rary=library.rlib && ./executable diff --git a/src/macros/dry.md b/src/macros/dry.md index a8c06112ca..7333d0e812 100644 --- a/src/macros/dry.md +++ b/src/macros/dry.md @@ -64,7 +64,7 @@ mod test { } ``` -```bash +```shell $ rustc --test dry.rs && ./dry running 3 tests test test::mul_assign ... ok diff --git a/src/meta/doc.md b/src/meta/doc.md index 2bb34e54ba..4aa2cbf0cc 100644 --- a/src/meta/doc.md +++ b/src/meta/doc.md @@ -60,7 +60,7 @@ fn main() { To run the tests, first build the code as a library, then tell rustdoc where to find the library so it can link it into each doctest program: -```bash +```shell $ rustc doc.rs --crate-type lib $ rustdoc --test --extern doc="libdoc.rlib" doc.rs ``` diff --git a/src/mod/split.md b/src/mod/split.md index a7d20aedac..634e7efae1 100644 --- a/src/mod/split.md +++ b/src/mod/split.md @@ -3,7 +3,7 @@ Modules can be mapped to a file/directory hierarchy. Let's break down the [visibility example][visibility] in files: -```bash +```shell $ tree . . |-- my @@ -84,7 +84,7 @@ pub fn public_function() { Let's check that things still work as before: -```bash +```shell $ rustc split.rs && ./split called `my::function()` called `function()` diff --git a/src/scope/raii.md b/src/scope/raii.md index 2b2071707e..7b6bca6184 100644 --- a/src/scope/raii.md +++ b/src/scope/raii.md @@ -41,7 +41,7 @@ fn main() { Of course, we can double check for memory errors using [`valgrind`][valgrind]: -```bash +```shell $ rustc raii.rs && valgrind ./raii ==26873== Memcheck, a memory error detector ==26873== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. diff --git a/src/std/panic.md b/src/std/panic.md index e9005ceb07..b22000494c 100644 --- a/src/std/panic.md +++ b/src/std/panic.md @@ -34,7 +34,7 @@ fn main() { Let's check that `panic!` doesn't leak memory. -```bash +```shell $ rustc panic.rs && valgrind ./panic ==4401== Memcheck, a memory error detector ==4401== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. diff --git a/src/std_misc/arg.md b/src/std_misc/arg.md index 751bf1d98c..b5dd89ce60 100644 --- a/src/std_misc/arg.md +++ b/src/std_misc/arg.md @@ -21,7 +21,7 @@ fn main() { } ``` -```bash +```shell $ ./args 1 2 3 My path is ./args. I got 3 arguments: ["1", "2", "3"]. diff --git a/src/std_misc/arg/matching.md b/src/std_misc/arg/matching.md index 984b05d92f..4cb68eabf0 100644 --- a/src/std_misc/arg/matching.md +++ b/src/std_misc/arg/matching.md @@ -70,7 +70,7 @@ fn main() { } ``` -```bash +```shell $ ./match_args Rust This is not the answer. $ ./match_args 42 diff --git a/src/std_misc/file/create.md b/src/std_misc/file/create.md index c2dc2ada9a..5fa63d58db 100644 --- a/src/std_misc/file/create.md +++ b/src/std_misc/file/create.md @@ -39,7 +39,7 @@ fn main() { Here's the expected successful output: -```bash +```shell $ mkdir out $ rustc create.rs && ./create successfully wrote to out/lorem_ipsum.txt diff --git a/src/std_misc/file/open.md b/src/std_misc/file/open.md index 2848b076e1..5056197f46 100644 --- a/src/std_misc/file/open.md +++ b/src/std_misc/file/open.md @@ -40,7 +40,7 @@ fn main() { Here's the expected successful output: -```bash +```shell $ echo "Hello World!" > hello.txt $ rustc open.rs && ./open hello.txt contains: diff --git a/src/std_misc/file/read_lines.md b/src/std_misc/file/read_lines.md index 2a2f1855dc..8972227fcb 100644 --- a/src/std_misc/file/read_lines.md +++ b/src/std_misc/file/read_lines.md @@ -33,7 +33,7 @@ where P: AsRef, { ``` Running this program simply prints the lines individually. -```bash +```shell $ echo -e "127.0.0.1\n192.168.0.1\n" > hosts $ rustc read_lines.rs && ./read_lines 127.0.0.1 diff --git a/src/std_misc/fs.md b/src/std_misc/fs.md index 0374c5a205..33612d7b3d 100644 --- a/src/std_misc/fs.md +++ b/src/std_misc/fs.md @@ -100,7 +100,7 @@ fn main() { Here's the expected successful output: -```bash +```shell $ rustc fs.rs && ./fs `mkdir a` `echo hello > a/b.txt` @@ -118,7 +118,7 @@ $ rustc fs.rs && ./fs And the final state of the `a` directory is: -```text +```shell $ tree a a |-- b.txt diff --git a/src/testing/dev_dependencies.md b/src/testing/dev_dependencies.md index b6302a90fb..4c08979e60 100644 --- a/src/testing/dev_dependencies.md +++ b/src/testing/dev_dependencies.md @@ -8,7 +8,7 @@ packages which depend on this package. One such example is using a crate that extends standard `assert!` macros. File `Cargo.toml`: -```ignore +```toml # standard crate data is left out [dev-dependencies] pretty_assertions = "0.4.0" diff --git a/src/testing/doc_testing.md b/src/testing/doc_testing.md index f25ffab285..1896ca556b 100644 --- a/src/testing/doc_testing.md +++ b/src/testing/doc_testing.md @@ -50,7 +50,7 @@ pub fn div(a: i32, b: i32) -> i32 { Tests can be run with `cargo test`: -```bash +```shell $ cargo test running 0 tests diff --git a/src/testing/integration_testing.md b/src/testing/integration_testing.md index d0e5122b51..2ab0d85a6e 100644 --- a/src/testing/integration_testing.md +++ b/src/testing/integration_testing.md @@ -30,7 +30,7 @@ fn test_add() { Running tests with `cargo test` command: -```bash +```shell $ cargo test running 0 tests diff --git a/src/testing/unit_testing.md b/src/testing/unit_testing.md index a6060e9c0d..7c401d3e81 100644 --- a/src/testing/unit_testing.md +++ b/src/testing/unit_testing.md @@ -48,7 +48,7 @@ mod tests { Tests can be run with `cargo test`. -```bash +```shell $ cargo test running 2 tests @@ -112,7 +112,7 @@ mod tests { Running these tests gives us: -```bash +```shell $ cargo test running 3 tests @@ -133,7 +133,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out To run specific tests one may specify the test name to `cargo test` command. -```bash +```shell $ cargo test test_any_panic running 1 test test tests::test_any_panic ... ok @@ -150,7 +150,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out To run multiple tests one may specify part of a test name that matches all the tests that should be run. -```bash +```shell $ cargo test panic running 2 tests test tests::test_any_panic ... ok @@ -198,7 +198,7 @@ mod tests { } ``` -```bash +```shell $ cargo test running 1 test test tests::ignored_test ... ignored