diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-06-28 16:05:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-28 16:05:12 +0200 |
| commit | cea2438834c29d516ea213d6ccd4836e6edab49d (patch) | |
| tree | 5ff1fa176f6c29aec7b9cca9ca557750542bc8cd | |
| parent | ea0dc9297283daff6486807f43e190b4eb561412 (diff) | |
| parent | e9f6c0f83a2f5e52d249b0a6d46d1c894936211a (diff) | |
| download | rust-cea2438834c29d516ea213d6ccd4836e6edab49d.tar.gz rust-cea2438834c29d516ea213d6ccd4836e6edab49d.zip | |
Rollup merge of #34080 - royalstream:royalstream-book-june4, r=steveklabnik
Syntax coloring and more compact diagram Two cosmetic improvements: - New content was added a few days ago to the **Closures** chapter but it was missing rust's syntax coloring. - Also, in the **Crates and Modules** chapter, a diagram was improved to be more symmetric and to take less space.
| -rw-r--r-- | src/doc/book/closures.md | 10 | ||||
| -rw-r--r-- | src/doc/book/crates-and-modules.md | 7 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md index dedf9d5c28a..a6b4e949218 100644 --- a/src/doc/book/closures.md +++ b/src/doc/book/closures.md @@ -322,7 +322,7 @@ to our closure when we pass it to `call_with_one`, so we use `&||`. A quick note about closures that use explicit lifetimes. Sometimes you might have a closure that takes a reference like so: -``` +```rust fn call_with_ref<F>(some_closure:F) -> i32 where F: Fn(&i32) -> i32 { @@ -334,8 +334,8 @@ fn call_with_ref<F>(some_closure:F) -> i32 Normally you can specify the lifetime of the parameter to our closure. We could annotate it on the function declaration: -```ignore -fn call_with_ref<'a, F>(some_closure:F) -> i32 +```rust,ignore +fn call_with_ref<'a, F>(some_closure:F) -> i32 where F: Fn(&'a 32) -> i32 { ``` @@ -353,11 +353,11 @@ fn call_with_ref<F>(some_closure:F) -> i32 where F: for<'a> Fn(&'a 32) -> i32 { ``` -This lets the Rust compiler find the minimum lifetime to invoke our closure and +This lets the Rust compiler find the minimum lifetime to invoke our closure and satisfy the borrow checker's rules. Our function then compiles and excutes as we expect. -``` +```rust fn call_with_ref<F>(some_closure:F) -> i32 where F: for<'a> Fn(&'a i32) -> i32 { diff --git a/src/doc/book/crates-and-modules.md b/src/doc/book/crates-and-modules.md index 43ac30c35c6..67fe8ba2c11 100644 --- a/src/doc/book/crates-and-modules.md +++ b/src/doc/book/crates-and-modules.md @@ -22,12 +22,10 @@ As an example, let’s make a *phrases* crate, which will give us various phrase in different languages. To keep things simple, we’ll stick to ‘greetings’ and ‘farewells’ as two kinds of phrases, and use English and Japanese (日本語) as two languages for those phrases to be in. We’ll use this module layout: - ```text +-----------+ +---| greetings | - | +-----------+ - +---------+ | + +---------+ | +-----------+ +---| english |---+ | +---------+ | +-----------+ | +---| farewells | @@ -37,8 +35,7 @@ two languages for those phrases to be in. We’ll use this module layout: | +---| greetings | | +----------+ | +-----------+ +---| japanese |--+ - +----------+ | - | +-----------+ + +----------+ | +-----------+ +---| farewells | +-----------+ ``` |
