Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rust-by-example
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1cce0737d6a7d3ceafb139b4a206861fb1dcb2ab
Choose a base ref
...
head repository: rust-lang/rust-by-example
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 03e23af01f0b4f83a3a513da280e1ca92587f2ec
Choose a head ref
  • 6 commits
  • 3 files changed
  • 4 contributors

Commits on Jan 3, 2021

  1. Add note for match guards to include catch-all

    The compiler doesn't check for conditions being exhausted when using arbitrary expressions (#74277).  This adds a note with example specifying that you need to cover all remaining conditions with `_`.
    
    My only concern is that my example may encourage people to use match guards as I did there, instead of something like:
    
    ```rust
        match number {
            0 => println!("Zero"),
            1..=u8::MAX => println!("Greater than zero"),
        }
    ```
    saward committed Jan 3, 2021
    Copy the full SHA
    9b02990 View commit details

Commits on Jan 4, 2021

  1. Merge pull request #1401 from saward/master

    Add note for match guards to include catch-all
    marioidival authored Jan 4, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7b47865 View commit details

Commits on Jan 5, 2021

  1. Update mdbook

    - Changelog to 0.4.5: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-045)
    - mdbook security advisory: https://blog.rust-lang.org/2021/01/04/mdbook-security-advisory.html
    
    Some breaking changes were introduced in 0.4.0 but I skimmed RBD built by 0.4.5 and no regression detected.
    weihanglo authored Jan 5, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f51daee View commit details
  2. Merge pull request #1402 from weihanglo/patch-1

    Update mdbook
    marioidival authored Jan 5, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    32e2dc8 View commit details

Commits on Jan 9, 2021

  1. Copy the full SHA
    4ff2dd8 View commit details
  2. Merge pull request #1404 from theidexisted/master

    Replace for loop with iteration
    marioidival authored Jan 9, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    03e23af View commit details
Showing with 19 additions and 11 deletions.
  1. +1 −1 .travis.yml
  2. +16 −0 src/flow_control/match/guard.md
  3. +2 −10 src/std_misc/threads/testcase_mapreduce.md
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ before_script:
set -ex
rustup --version
rustc -Vv
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.3.7/mdbook-v0.3.7-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=$HOME/.cargo/bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.5/mdbook-v0.4.5-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=$HOME/.cargo/bin
mdbook --version
rustup toolchain update nightly -c rust-docs
script:
16 changes: 16 additions & 0 deletions src/flow_control/match/guard.md
Original file line number Diff line number Diff line change
@@ -18,6 +18,22 @@ fn main() {
}
```

Note that the compiler does not check arbitrary expressions for whether all
possible conditions have been checked. Therefore, you must use the `_` pattern
at the end.

```rust,editable
fn main() {
let number: u8 = 4;
match number {
i if i == 0 => println!("Zero"),
i if i > 0 => println!("Greater than zero"),
_ => println!("Fell through"), // This should not be possible to reach
}
}
```

### See also:

[Tuples](../../primitives/tuples.md)
12 changes: 2 additions & 10 deletions src/std_misc/threads/testcase_mapreduce.md
Original file line number Diff line number Diff line change
@@ -103,21 +103,13 @@ fn main() {
* Collect our intermediate results, and combine them into a final result
************************************************************************/
// collect each thread's intermediate results into a new Vec
let mut intermediate_sums = vec![];
for child in children {
// collect each child thread's return-value
let intermediate_sum = child.join().unwrap();
intermediate_sums.push(intermediate_sum);
}
// combine all intermediate sums into a single final sum.
// combine each thread's intermediate results into a single final sum.
//
// we use the "turbofish" ::<> to provide sum() with a type hint.
//
// TODO: try without the turbofish, by instead explicitly
// specifying the type of final_result
let final_result = intermediate_sums.iter().sum::<u32>();
let final_result = children.into_iter().map(|c| c.join().unwrap()).sum::<u32>();
println!("Final sum result: {}", final_result);
}