Skip to content

Commit abcacb2

Browse files
More formal writing and links
1 parent d845bc3 commit abcacb2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/patterns.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ match tuple {
402402
> **<sup>Syntax</sup>**\
403403
> _RangePattern_ :\
404404
> &nbsp;&nbsp; _RangePatternBound_ `..=` _RangePatternBound_
405-
> _RangeFromPattern_ :\
406405
> &nbsp;&nbsp; _RangePatternBound_ `..`
407406
>
408407
> _ObsoleteRangePattern_ :\
@@ -416,10 +415,16 @@ match tuple {
416415
> &nbsp;&nbsp; | [_PathInExpression_]\
417416
> &nbsp;&nbsp; | [_QualifiedPathInExpression_]
418417
419-
Range patterns match values that are within a range defined by its lower and upper bounds (if any).
420-
For example, a pattern `'m'..='p'` will match only the values `'m'`, `'n'`, `'o'`, and `'p'`. A
421-
pattern `1..` will match values equal to or greater than 1, but not 0 (or negative numbers, for
422-
signed integers). The bounds can be literals or paths that point to constant values.
418+
Range patterns match values within the range defined by their bounds. A range pattern may be
419+
closed or half-open. A range pattern is closed if it has both a lower and an upper bound, and
420+
it matches all the values between and including both of its bounds. A range pattern that is
421+
half-open is written with a lower bound but not an upper bound, and matches any value equal to
422+
or greater than the specified lower bound.
423+
424+
For example, a pattern `'m'..='p'` will match only the values `'m'`, `'n'`, `'o'`, and `'p'`. The
425+
pattern `1..` will match 9, or 9001, or 9007199254740991 (if it is of an appropriate size), but
426+
not 0 or negative numbers for signed integers. The bounds can be literals or paths that point
427+
to constant values.
423428

424429
A pattern a `..=` b must always have a &le; b. It is an error to have a range pattern
425430
`10..=0`, for example.

src/tokens.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ usages and meanings are defined in the linked pages.
586586
| `@` | At | [Subpattern binding]
587587
| `_` | Underscore | [Wildcard patterns], [Inferred types], Unnamed items in [constants], [extern crates], and [use declarations]
588588
| `.` | Dot | [Field access][field], [Tuple index]
589-
| `..` | DotDot | [Range][range], [Struct expressions], [Patterns]
589+
| `..` | DotDot | [Range][range], [Struct expressions], [Patterns], [Range Patterns][rangepat]
590590
| `...` | DotDotDot | [Variadic functions][extern], [Range patterns]
591591
| `..=` | DotDotEq | [Inclusive Range][range], [Range patterns]
592592
| `,` | Comma | Various separators
@@ -646,6 +646,7 @@ them are referred to as "token trees" in [macros]. The three types of brackets
646646
[patterns]: patterns.md
647647
[question]: expressions/operator-expr.md#the-question-mark-operator
648648
[range]: expressions/range-expr.md
649+
[rangepat]: patterns.md#range-patterns
649650
[raw pointers]: types/pointer.md#raw-pointers-const-and-mut
650651
[references]: types/pointer.md
651652
[sized]: trait-bounds.md#sized

0 commit comments

Comments
 (0)