Skip to content

Commit cea2438

Browse files
Rollup merge of rust-lang#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.
2 parents ea0dc92 + e9f6c0f commit cea2438

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/doc/book/closures.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ to our closure when we pass it to `call_with_one`, so we use `&||`.
322322
A quick note about closures that use explicit lifetimes. Sometimes you might have a closure
323323
that takes a reference like so:
324324

325-
```
325+
```rust
326326
fn call_with_ref<F>(some_closure:F) -> i32
327327
where F: Fn(&i32) -> i32 {
328328

@@ -334,8 +334,8 @@ fn call_with_ref<F>(some_closure:F) -> i32
334334
Normally you can specify the lifetime of the parameter to our closure. We
335335
could annotate it on the function declaration:
336336

337-
```ignore
338-
fn call_with_ref<'a, F>(some_closure:F) -> i32
337+
```rust,ignore
338+
fn call_with_ref<'a, F>(some_closure:F) -> i32
339339
where F: Fn(&'a 32) -> i32 {
340340
```
341341

@@ -353,11 +353,11 @@ fn call_with_ref<F>(some_closure:F) -> i32
353353
where F: for<'a> Fn(&'a 32) -> i32 {
354354
```
355355

356-
This lets the Rust compiler find the minimum lifetime to invoke our closure and
356+
This lets the Rust compiler find the minimum lifetime to invoke our closure and
357357
satisfy the borrow checker's rules. Our function then compiles and excutes as we
358358
expect.
359359

360-
```
360+
```rust
361361
fn call_with_ref<F>(some_closure:F) -> i32
362362
where F: for<'a> Fn(&'a i32) -> i32 {
363363

src/doc/book/crates-and-modules.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ As an example, let’s make a *phrases* crate, which will give us various phrase
2222
in different languages. To keep things simple, we’ll stick to ‘greetings’ and
2323
‘farewells’ as two kinds of phrases, and use English and Japanese (日本語) as
2424
two languages for those phrases to be in. We’ll use this module layout:
25-
2625
```text
2726
+-----------+
2827
+---| greetings |
29-
| +-----------+
30-
+---------+ |
28+
+---------+ | +-----------+
3129
+---| english |---+
3230
| +---------+ | +-----------+
3331
| +---| farewells |
@@ -37,8 +35,7 @@ two languages for those phrases to be in. We’ll use this module layout:
3735
| +---| greetings |
3836
| +----------+ | +-----------+
3937
+---| japanese |--+
40-
+----------+ |
41-
| +-----------+
38+
+----------+ | +-----------+
4239
+---| farewells |
4340
+-----------+
4441
```

0 commit comments

Comments
 (0)