Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update let-else example with main function #1711

Merged
merged 1 commit into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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