Skip to content

Commit dfc44e4

Browse files
authored
Merge pull request #1765 from ravicodelabs/minor-edits
Various minor edits for typo fixes, formatting fixes, and clarifications
2 parents 5cda62c + 914a935 commit dfc44e4

File tree

10 files changed

+32
-24
lines changed

10 files changed

+32
-24
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() {

src/error/multiple_error_types/boxing_errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ via [`From`][from].
1212
use std::error;
1313
use std::fmt;
1414
15-
// Change the alias to `Box<error::Error>`.
15+
// Change the alias to use `Box<dyn error::Error>`.
1616
type Result<T> = std::result::Result<T, Box<dyn error::Error>>;
1717
1818
#[derive(Debug, Clone)]

src/error/multiple_error_types/reenter_question_mark.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Here, we rewrite the previous example using `?`. As a result, the
2626
use std::error;
2727
use std::fmt;
2828
29-
// Change the alias to `Box<dyn error::Error>`.
29+
// Change the alias to use `Box<dyn error::Error>`.
3030
type Result<T> = std::result::Result<T, Box<dyn error::Error>>;
3131
3232
#[derive(Debug)]

src/error/option_unwrap/defaults.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Another alternative is to use `or_else`, which is also chainable, and evaluates
3838
enum Fruit { Apple, Orange, Banana, Kiwi, Lemon }
3939
4040
fn main() {
41-
let apple = Some(Fruit::Apple);
4241
let no_fruit: Option<Fruit> = None;
4342
let get_kiwi_as_fallback = || {
4443
println!("Providing kiwi as fallback");

src/flow_control/match/guard.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ fn main() {
1616
match temperature {
1717
Temperature::Celsius(t) if t > 30 => println!("{}C is above 30 Celsius", t),
1818
// The `if condition` part ^ is a guard
19-
Temperature::Celsius(t) => println!("{}C is below 30 Celsius", t),
19+
Temperature::Celsius(t) => println!("{}C is equal to or below 30 Celsius", t),
2020
2121
Temperature::Fahrenheit(t) if t > 86 => println!("{}F is above 86 Fahrenheit", t),
22-
Temperature::Fahrenheit(t) => println!("{}F is below 86 Fahrenheit", t),
22+
Temperature::Fahrenheit(t) => println!("{}F is equal to or below 86 Fahrenheit", t),
2323
}
2424
}
2525
```

src/fn/closures/capture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn main() {
4444
// borrows `count`.
4545
//
4646
// A `mut` is required on `inc` because a `&mut` is stored inside. Thus,
47-
// calling the closure mutates the closure which requires a `mut`.
47+
// calling the closure mutates `count` which requires a `mut`.
4848
let mut inc = || {
4949
count += 1;
5050
println!("`count`: {}", count);

src/macros/dsl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ an expression and have the output printed to console.
1212
macro_rules! calculate {
1313
(eval $e:expr) => {
1414
{
15-
let val: usize = $e; // Force types to be integers
15+
let val: usize = $e; // Force types to be unsigned integers
1616
println!("{} = {}", stringify!{$e}, val);
1717
}
1818
};

src/meta/playground.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
```
1515

1616
This allows the reader to both run your code sample, but also modify and tweak
17-
it. The key here is the adding the word `editable` to your codefence block
17+
it. The key here is the adding of the word `editable` to your codefence block
1818
separated by a comma.
1919

2020
````markdown

src/trait/clone.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ fn main() {
4040
4141
// Clone `moved_pair` into `cloned_pair` (resources are included)
4242
let cloned_pair = moved_pair.clone();
43-
// Drop the original pair using std::mem::drop
43+
// Drop the moved original pair using std::mem::drop
4444
drop(moved_pair);
4545
4646
// Error! `moved_pair` has been dropped
47-
//println!("copy: {:?}", moved_pair);
47+
//println!("moved and dropped: {:?}", moved_pair);
4848
// TODO ^ Try uncommenting this line
4949
5050
// The result from .clone() can still be used!

src/trait/disambiguating.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Disambiguating overlapping traits
22

33
A type can implement many different traits. What if two traits both require
4-
the same name? For example, many traits might have a method named `get()`.
5-
They might even have different return types!
4+
the same name for a function? For example, many traits might have a method
5+
named `get()`. They might even have different return types!
66

77
Good news: because each trait implementation gets its own `impl` block, it's
88
clear which trait's `get` method you're implementing.

0 commit comments

Comments
 (0)