Skip to content

Commit 9153f28

Browse files
committed
Various minor formatting edits
1 parent ff939dd commit 9153f28

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/error/abort_unwind.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ The previous section illustrates the error handling mechanism `panic`. Differen
66
Building on the prior lemonade example, we explicitly use the panic strategy to exercise different lines of code.
77

88
```rust,editable,mdbook-runnable
9-
109
fn drink(beverage: &str) {
11-
// You shouldn't drink too much sugary beverages.
10+
// You shouldn't drink too much sugary beverages.
1211
if beverage == "lemonade" {
13-
if cfg!(panic="abort"){ println!("This is not your party. Run!!!!");}
14-
else{ println!("Spit it out!!!!");}
12+
if cfg!(panic = "abort") {
13+
println!("This is not your party. Run!!!!");
14+
} else {
15+
println!("Spit it out!!!!");
16+
}
17+
} else {
18+
println!("Some refreshing {} is all I need.", beverage);
1519
}
16-
else{ println!("Some refreshing {} is all I need.", beverage); }
1720
}
1821
1922
fn main() {
@@ -25,16 +28,22 @@ fn main() {
2528
Here is another example focusing on rewriting `drink()` and explicitly use the `unwind` keyword.
2629

2730
```rust,editable
28-
2931
#[cfg(panic = "unwind")]
30-
fn ah(){ println!("Spit it out!!!!");}
32+
fn ah() {
33+
println!("Spit it out!!!!");
34+
}
3135
32-
#[cfg(not(panic="unwind"))]
33-
fn ah(){ println!("This is not your party. Run!!!!");}
36+
#[cfg(not(panic = "unwind"))]
37+
fn ah() {
38+
println!("This is not your party. Run!!!!");
39+
}
3440
35-
fn drink(beverage: &str){
36-
if beverage == "lemonade"{ ah();}
37-
else{println!("Some refreshing {} is all I need.", beverage);}
41+
fn drink(beverage: &str) {
42+
if beverage == "lemonade" {
43+
ah();
44+
} else {
45+
println!("Some refreshing {} is all I need.", beverage);
46+
}
3847
}
3948
4049
fn main() {

0 commit comments

Comments
 (0)