Skip to content

Commit 42a6caf

Browse files
authored
Merge branch 'rust-lang:master' into patch-2
2 parents 00f17a9 + 8957a71 commit 42a6caf

File tree

12 files changed

+36
-28
lines changed

12 files changed

+36
-28
lines changed

src/cargo/test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ $ cargo test
4242
Finished dev [unoptimized + debuginfo] target(s) in 0.89 secs
4343
Running target/debug/deps/blah-d3b32b97275ec472
4444

45-
running 3 tests
45+
running 4 tests
4646
test test_bar ... ok
4747
test test_baz ... ok
4848
test test_foo_bar ... ok
4949
test test_foo ... ok
5050

51-
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
51+
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
5252
```
5353

5454
You can also run tests whose name matches a pattern:
@@ -135,7 +135,7 @@ Corro
135135
```
136136
What actually gets put into `ferris.txt` is this:
137137
```shell
138-
$ cargo test test_foo
138+
$ cargo test test_file && cat ferris.txt
139139
Corro
140140
Ferris
141141
Corro

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.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ variable names *must* be specified.
1414

1515
Other characteristics of closures include:
1616
* using `||` instead of `()` around input variables.
17-
* optional body delimitation (`{}`) for a single expression (mandatory otherwise).
17+
* optional body delimitation (`{}`) for a single line expression (mandatory otherwise).
1818
* the ability to capture the outer environment variables.
1919

2020
```rust,editable

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

0 commit comments

Comments
 (0)