Skip to content

Commit 3fe2de1

Browse files
authored
Merge pull request #2093 from theemathas/patch-1
Specify that range patterns must be nonempty.
2 parents 93f3388 + de7d887 commit 3fe2de1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/patterns.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,12 @@ It is written as `..=` followed by the upper bound.
554554

555555
For example, `..=10` will match any integer less than or equal to 10, such as 10, 1, 0, and for signed integer types, all negative values.
556556

557-
r[patterns.range.constraint-less-than]
558-
The lower bound cannot be greater than the upper bound.
559-
That is, in `a..=b`, a ≤ b must be the case.
560-
For example, it is an error to have a range pattern `10..=0`.
557+
r[patterns.range.constraint-nonempty]
558+
A range pattern must be nonempty; it must span at least one value in the set of possible values for its type. In other words:
559+
560+
* In `a..=b`, a ≤ b must be the case. For example, it is an error to have a range pattern `10..=0`, but `10..=10` is allowed.
561+
* In `a..b`, a < b must be the case. For example, it is an error to have a range pattern `10..0` or `10..10`.
562+
* In `..b`, b must not be the smallest value of its type. For example, it is an error to have a range pattern `..-128i8` or `..f64::NEG_INFINITY`.
561563

562564
r[patterns.range.bound]
563565
A bound is written as one of:

0 commit comments

Comments
 (0)