Skip to content
Open
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
10 changes: 6 additions & 4 deletions src/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,12 @@ It is written as `..=` followed by the upper bound.

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.

r[patterns.range.constraint-less-than]
The lower bound cannot be greater than the upper bound.
That is, in `a..=b`, a ≤ b must be the case.
For example, it is an error to have a range pattern `10..=0`.
r[patterns.range.constraint-nonempty]
A range pattern must match at least one possible value. In other words:

* 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.
* 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`.
* 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`.

r[patterns.range.bound]
A bound is written as one of:
Expand Down