Skip to content

Commit

Permalink
Merge pull request #1890 from Plotnus/patch-1
Browse files Browse the repository at this point in the history
Update range so matches rust-fmt .
  • Loading branch information
carols10cents authored Apr 15, 2019
2 parents c973f37 + a0a8516 commit c231bf7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ch18-03-pattern-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ arm will execute:
let x = 5;

match x {
1 ... 5 => println!("one through five"),
1...5 => println!("one through five"),
_ => println!("something else"),
}
```

If `x` is 1, 2, 3, 4, or 5, the first arm will match. This syntax is more
convenient than using the `|` operator to express the same idea; instead of `1
... 5`, we would have to specify `1 | 2 | 3 | 4 | 5` if we used `|`. Specifying
a range is much shorter, especially if we want to match, say, any number
between 1 and 1,000!
convenient than using the `|` operator to express the same idea; instead of
`1...5`, we would have to specify `1 | 2 | 3 | 4 | 5` if we used `|`.
Specifying a range is much shorter, especially if we want to match, say, any
number between 1 and 1,000!

Ranges are only allowed with numeric values or `char` values, because the
compiler checks that the range isn’t empty at compile time. The only types for
Expand All @@ -136,8 +136,8 @@ Here is an example using ranges of `char` values:
let x = 'c';

match x {
'a' ... 'j' => println!("early ASCII letter"),
'k' ... 'z' => println!("late ASCII letter"),
'a'...'j' => println!("early ASCII letter"),
'k'...'z' => println!("late ASCII letter"),
_ => println!("something else"),
}
```
Expand Down

0 comments on commit c231bf7

Please sign in to comment.