You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/error/abort_unwind.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
The previous section illustrates the error handling mechanism `panic`. Different code paths can be conditionally compiled based on the panic setting. The current values available are `unwind` and `abort`.
4
4
5
-
Building on the prior lemonade example, we explicitly use the panic strategy to exercise different lines of code.
5
+
Building on the prior lemonade example, we explicitly use the panic strategy to exercise different lines of code.
Copy file name to clipboardExpand all lines: src/error/option_unwrap/defaults.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ There is more than one way to unpack an `Option` and fall back on a default if i
10
10
`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.
11
11
12
12
```rust,editable
13
-
#[derive(Debug)]
13
+
#[derive(Debug)]
14
14
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
15
15
16
16
fn main() {
@@ -27,15 +27,15 @@ fn main() {
27
27
// But the variable named `apple` has been moved regardless, and cannot be used anymore.
28
28
// println!("Variable apple was moved, so this line won't compile: {:?}", apple);
29
29
// TODO: uncomment the line above to see the compiler error
30
-
}
30
+
}
31
31
```
32
32
33
33
## `or_else()` is chainable, evaluates lazily, keeps empty value intact
34
34
35
35
Another alternative is to use `or_else`, which is also chainable, and evaluates lazily, as is shown in the following example:
36
36
37
37
```rust,editable
38
-
#[derive(Debug)]
38
+
#[derive(Debug)]
39
39
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
40
40
41
41
fn main() {
@@ -84,7 +84,7 @@ fn main() {
84
84
Instead of explicitly providing a value to fall back on, we can pass a closure to `get_or_insert_with`, as follows:
0 commit comments