Skip to content

Commit ec44dbf

Browse files
authored
Make rust editable in chapter on defaults (#1589)
* make-rust-editable-in-chapter-on-defaults * im-to-in-fix-typo
1 parent ee342dc commit ec44dbf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/error/option_unwrap/defaults.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The is more than one way to unpack an `Option` and fall back on a default if it
88

99
`or()`is chainable and eagerly evaluates its argument, as is shown in the following example. Note that because `or`'s arguments are evaluated eagerly, the variable passed to `or` is moved.
1010

11-
```
11+
```rust,editable
1212
#[derive(Debug)]
1313
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
1414
@@ -33,7 +33,7 @@ fn main() {
3333

3434
Another alternative is to use `or_else`, which is also chainable, and evaluates lazily, as is shown in the following example:
3535

36-
```
36+
```rust,editable
3737
#[derive(Debug)]
3838
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
3939
@@ -58,11 +58,11 @@ fn main() {
5858
}
5959
```
6060

61-
## `get_or_insert()` evaluates eagerly, modifies empty value im place
61+
## `get_or_insert()` evaluates eagerly, modifies empty value in place
6262

6363
To make sure that an `Option` contains a value, we can use `get_or_insert` to modify it in place with a fallback value, as is shown in the following example. Note that `get_or_insert` eagerly evaluaes its parameter, so variable `apple` is moved:
6464

65-
```
65+
```rust,editable
6666
#[derive(Debug)]
6767
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
6868
@@ -79,10 +79,10 @@ fn main() {
7979
}
8080
```
8181

82-
## `get_or_insert_with()` evaluates lazily, modifies empty value im place
82+
## `get_or_insert_with()` evaluates lazily, modifies empty value in place
8383

8484
Instead of explicitly providing a value to fall back on, we can pass a closure to `get_or_insert_with`, as follows:
85-
```
85+
```rust,editable
8686
#[derive(Debug)]
8787
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
8888

0 commit comments

Comments
 (0)