Skip to content

Commit 101376c

Browse files
authored
Update range pattern refutability
Range patterns may now be irrefutable, as of `exhaustive_integer_patterns`.
1 parent e5751c9 commit 101376c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/patterns.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ println!("{}", match 0xfacade {
418418
});
419419
```
420420

421-
Range patterns are always refutable, even when they cover the complete set
422-
of possible values of a type. For example, `0u8..=255u8` is refutable even though
423-
it covers all possible values of `u8`.
421+
Range patterns for (non-`usize` and -`isize`) integer and `char` types are irrefutable
422+
when they span the entire set of possible values of a type. For example, `0u8..=255u8`
423+
is irrefutable. The range of values for an integer type is the closed range from its
424+
minimum to maximum value. The range of values for a `char` type are precisely those
425+
ranges containing all Unicode Scalar Values: `'\u{0000}'..='\u{D7FF}'` and
426+
`'\u{E000}'..='\u{10FFFF}'`.
424427

425428
## Reference patterns
426429

0 commit comments

Comments
 (0)