Skip to content

Commit

Permalink
Merge pull request #1711 from bmwant/bmwant/fix-let-else-example
Browse files Browse the repository at this point in the history
Update let-else example with main function
  • Loading branch information
marioidival authored May 29, 2023
2 parents a071456 + 452ba02 commit 940beaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ We use the following labels:

## Development workflow

To build RBE, [install Rust], and then:
To build RBE, [install Rust](https://www.rust-lang.org/tools/install), and then:

```bash
$ git clone https://github.com/rust-lang/rust-by-example
Expand All @@ -56,7 +56,7 @@ $ mdbook build
[install Rust]: http://rust-lang.org/install.html

The files will be in the `book` directory at the top-level; `mdbook serve` will
open the contents in your web browser.
open the contents in your web browser ([localhost:3000](http://localhost:3000) by default).

To run the tests:

Expand Down
7 changes: 6 additions & 1 deletion src/flow_control/let_else.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


> 🛈 stable since: rust 1.65
>
> 🛈 you can target specific edition by compiling like this
> `rustc --edition=2021 main.rs`

With `let`-`else`, a refutable pattern can match and bind variables
Expand All @@ -22,7 +25,9 @@ fn get_count_item(s: &str) -> (u64, &str) {
(count, item)
}

assert_eq!(get_count_item("3 chairs"), (3, "chairs"));
fn main() {
assert_eq!(get_count_item("3 chairs"), (3, "chairs"));
}
```

The scope of name bindings is the main thing that makes this different from
Expand Down

0 comments on commit 940beaa

Please sign in to comment.