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

Clarify slice patterns example #223

Merged
merged 1 commit into from
Nov 2, 2020
Merged
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
6 changes: 3 additions & 3 deletions src/rust-2018/slice-patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
greet(&["Alan"]);
// output: Hey, there Alan! You seem to be alone.
greet(&["Joan", "Hugh"]);
// output: Hello, Joan and Hugh. Nice to see you are at least 2!
// output: Hello, Joan and Hugh. Nice to see you are exactly 2!
greet(&["John", "Peter", "Stewart"]);
// output: Hey everyone, we seem to be 3 here today.
}
Expand All @@ -25,7 +25,7 @@ fn greet(people: &[&str]) {
[] => println!("Bummer, there's no one here :("),
[only_one] => println!("Hey, there {}! You seem to be alone.", only_one),
[first, second] => println!(
"Hello, {} and {}. Nice to see you are at least 2!",
"Hello, {} and {}. Nice to see you are exactly 2!",
first, second
),
_ => println!("Hey everyone, we seem to be {} here today.", people.len()),
Expand Down Expand Up @@ -88,4 +88,4 @@ error[E0527]: pattern requires 4 elements but array has 3
[the tracking issue]: https://github.com/rust-lang/rust/issues/23121

When it comes to slice patterns, more advanced forms are planned but
have not been stabilized yet. To learn more, follow [the tracking issue].
have not been stabilized yet. To learn more, follow [the tracking issue].