diff options
| -rw-r--r-- | src/doc/trpl/benchmark-tests.md | 4 | ||||
| -rw-r--r-- | src/doc/trpl/box-syntax-and-patterns.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/crates-and-modules.md | 38 | ||||
| -rw-r--r-- | src/doc/trpl/error-handling.md | 8 | ||||
| -rw-r--r-- | src/doc/trpl/iterators.md | 6 | ||||
| -rw-r--r-- | src/doc/trpl/testing.md | 10 | ||||
| -rw-r--r-- | src/doc/trpl/while-loops.md | 2 |
7 files changed, 35 insertions, 35 deletions
diff --git a/src/doc/trpl/benchmark-tests.md b/src/doc/trpl/benchmark-tests.md index 88796537593..797ec94774d 100644 --- a/src/doc/trpl/benchmark-tests.md +++ b/src/doc/trpl/benchmark-tests.md @@ -3,7 +3,7 @@ Rust supports benchmark tests, which can test the performance of your code. Let's make our `src/lib.rs` look like this (comments elided): -```{rust,ignore} +```rust,ignore #![feature(test)] extern crate test; @@ -77,7 +77,7 @@ the benchmark is no longer benchmarking what one expects. For example, the compiler might recognize that some calculation has no external effects and remove it entirely. -```{rust,ignore} +```rust,ignore #![feature(test)] extern crate test; diff --git a/src/doc/trpl/box-syntax-and-patterns.md b/src/doc/trpl/box-syntax-and-patterns.md index dc1abc5d06a..1cf84bfd658 100644 --- a/src/doc/trpl/box-syntax-and-patterns.md +++ b/src/doc/trpl/box-syntax-and-patterns.md @@ -34,7 +34,7 @@ because the syntax may still change in the future. In many languages with pointers, you'd return a pointer from a function so as to avoid copying a large data structure. For example: -```{rust} +```rust struct BigStruct { one: i32, two: i32, diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md index d5970e2e491..63fdef0760f 100644 --- a/src/doc/trpl/crates-and-modules.md +++ b/src/doc/trpl/crates-and-modules.md @@ -126,7 +126,7 @@ ways. Instead of declaring a module like this: -```{rust,ignore} +```rust,ignore mod english { // contents of our module go here } @@ -134,7 +134,7 @@ mod english { We can instead declare our module like this: -```{rust,ignore} +```rust,ignore mod english; ``` @@ -173,7 +173,7 @@ $ tree . `src/lib.rs` is our crate root, and looks like this: -```{rust,ignore} +```rust,ignore mod english; mod japanese; ``` @@ -184,7 +184,7 @@ on our preference. In this case, because our modules have sub-modules, we’ve chosen the second. Both `src/english/mod.rs` and `src/japanese/mod.rs` look like this: -```{rust,ignore} +```rust,ignore mod greetings; mod farewells; ``` @@ -297,7 +297,7 @@ public, and so private is the default. To make things public, you use the `pub` keyword. Let’s focus on the `english` module first, so let’s reduce our `src/main.rs` to just this: -```{rust,ignore} +```rust,ignore extern crate phrases; fn main() { @@ -308,21 +308,21 @@ fn main() { In our `src/lib.rs`, let’s add `pub` to the `english` module declaration: -```{rust,ignore} +```rust,ignore pub mod english; mod japanese; ``` And in our `src/english/mod.rs`, let’s make both `pub`: -```{rust,ignore} +```rust,ignore pub mod greetings; pub mod farewells; ``` In our `src/english/greetings.rs`, let’s add `pub` to our `fn` declaration: -```{rust,ignore} +```rust,ignore pub fn hello() -> String { "Hello!".to_string() } @@ -330,7 +330,7 @@ pub fn hello() -> String { And also in `src/english/farewells.rs`: -```{rust,ignore} +```rust,ignore pub fn goodbye() -> String { "Goodbye.".to_string() } @@ -365,7 +365,7 @@ refer to them with shorter names. Let’s talk about `use`. Rust has a `use` keyword, which allows us to import names into our local scope. Let’s change our `src/main.rs` to look like this: -```{rust,ignore} +```rust,ignore extern crate phrases; use phrases::english::greetings; @@ -382,7 +382,7 @@ the functions by a much shorter name. By convention, when importing functions, i considered best practice to import the module, rather than the function directly. In other words, you _can_ do this: -```{rust,ignore} +```rust,ignore extern crate phrases; use phrases::english::greetings::hello; @@ -400,7 +400,7 @@ becomes a problem. If we have conflicting names, Rust will give a compilation error. For example, if we made the `japanese` functions public, and tried to do this: -```{rust,ignore} +```rust,ignore extern crate phrases; use phrases::english::greetings::hello; @@ -426,14 +426,14 @@ Could not compile `phrases`. If we’re importing multiple names from the same module, we don’t have to type it out twice. Instead of this: -```{rust,ignore} +```rust,ignore use phrases::english::greetings; use phrases::english::farewells; ``` We can use this shortcut: -```{rust,ignore} +```rust,ignore use phrases::english::{greetings, farewells}; ``` @@ -445,7 +445,7 @@ interface that may not directly map to your internal code organization. Let’s look at an example. Modify your `src/main.rs` to read like this: -```{rust,ignore} +```rust,ignore extern crate phrases; use phrases::english::{greetings,farewells}; @@ -462,14 +462,14 @@ fn main() { Then, modify your `src/lib.rs` to make the `japanese` mod public: -```{rust,ignore} +```rust,ignore pub mod english; pub mod japanese; ``` Next, make the two functions public, first in `src/japanese/greetings.rs`: -```{rust,ignore} +```rust,ignore pub fn hello() -> String { "こんにちは".to_string() } @@ -477,7 +477,7 @@ pub fn hello() -> String { And then in `src/japanese/farewells.rs`: -```{rust,ignore} +```rust,ignore pub fn goodbye() -> String { "さようなら".to_string() } @@ -485,7 +485,7 @@ pub fn goodbye() -> String { Finally, modify your `src/japanese/mod.rs` to read like this: -```{rust,ignore} +```rust,ignore pub use self::greetings::hello; pub use self::farewells::goodbye; diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index dcaf698fd3c..7b47559e0fc 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -49,7 +49,7 @@ We use `assert!` to declare that something is true. If it's not true, something is very wrong. Wrong enough that we can't continue with things in the current state. Another example is using the `unreachable!()` macro: -```{rust,ignore} +```rust,ignore enum Event { NewRelease, } @@ -188,7 +188,7 @@ The [`Debug`](../std/fmt/trait.Debug.html) trait is what lets us print the enum In the case of an error that is unexpected and not recoverable, the `panic!` macro will induce a panic. This will crash the current thread, and give an error: -```{rust,ignore} +```rust,ignore panic!("boom"); ``` @@ -212,7 +212,7 @@ handle and possibly recover from error. If we don't want to handle this error, and would rather just abort the program, we can use the `unwrap()` method: -```{rust,ignore} +```rust,ignore io::stdin().read_line(&mut buffer).unwrap(); ``` @@ -223,7 +223,7 @@ shorter. Sometimes, just crashing is appropriate. There's another way of doing this that's a bit nicer than `unwrap()`: -```{rust,ignore} +```rust,ignore let mut buffer = String::new(); let input = io::stdin().read_line(&mut buffer) .ok() diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index a93f622e9c5..80c0def285a 100644 --- a/src/doc/trpl/iterators.md +++ b/src/doc/trpl/iterators.md @@ -116,7 +116,7 @@ A *consumer* operates on an iterator, returning some kind of value or values. The most common consumer is `collect()`. This code doesn't quite compile, but it shows the intention: -```{rust,ignore} +```rust,ignore let one_to_one_hundred = (1..101).collect(); ``` @@ -253,7 +253,7 @@ we need to talk about with regards to iterators. Let's get to it! *Iterator adapters* take an iterator and modify it somehow, producing a new iterator. The simplest one is called `map`: -```{rust,ignore} +```rust,ignore (1..100).map(|x| x + 1); ``` @@ -272,7 +272,7 @@ warning: unused result which must be used: iterator adaptors are lazy and Laziness strikes again! That closure will never execute. This example doesn't print any numbers: -```{rust,ignore} +```rust,ignore (1..100).map(|x| println!("{}", x)); ``` diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md index f5fdb8f8590..759543140b5 100644 --- a/src/doc/trpl/testing.md +++ b/src/doc/trpl/testing.md @@ -205,7 +205,7 @@ fn it_works() { That's all there is to the basics! Let's write one 'real' test: -```{rust,ignore} +```rust,ignore pub fn add_two(a: i32) -> i32 { a + 2 } @@ -225,7 +225,7 @@ There is one way in which our existing example is not idiomatic: it's missing the `tests` module. The idiomatic way of writing our example looks like this: -```{rust,ignore} +```rust,ignore pub fn add_two(a: i32) -> i32 { a + 2 } @@ -253,7 +253,7 @@ we need to bring our test function into scope. This can be annoying if you have a large module, and so this is a common use of the `glob` feature. Let's change our `src/lib.rs` to make use of it: -```{rust,ignore} +```rust,ignore pub fn add_two(a: i32) -> i32 { a + 2 @@ -302,7 +302,7 @@ the `tests` directory To write an integration test, let's make a `tests` directory, and put a `tests/lib.rs` file inside, with this as its contents: -```{rust,ignore} +```rust,ignore extern crate adder; #[test] @@ -359,7 +359,7 @@ documentation has been written. To this end, Rust supports automatically running examples in your documentation. Here's a fleshed-out `src/lib.rs` with examples: -```{rust,ignore} +```rust,ignore //! The `adder` crate provides functions that add numbers to other numbers. //! //! # Examples diff --git a/src/doc/trpl/while-loops.md b/src/doc/trpl/while-loops.md index a56c546b551..0f5c3c64a4b 100644 --- a/src/doc/trpl/while-loops.md +++ b/src/doc/trpl/while-loops.md @@ -2,7 +2,7 @@ Rust also has a `while` loop. It looks like this: -```{rust} +```rust let mut x = 5; // mut x: i32 let mut done = false; // mut done: bool |
