You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/patterns.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -776,7 +776,7 @@ They are refutable when they refer to refutable constants or enum variants for e
776
776
When a constant `C` of type `T` is used as a pattern, we first check that `T: PartialEq`.
777
777
Furthermore we require that the value of `C`*has (recursive) structural equality*, which is defined recursively as follows:
778
778
779
-
- Integers as well as `bool` and `char` values always have structural equality.
779
+
- Integers as well as `str`, `bool` and `char` values always have structural equality.
780
780
- Tuples, arrays, and slices have structural equality if all their fields/elements have structural equality.
781
781
(In particular, `()` and `[]` always have structural equality.)
782
782
- References have structural equality if the value they point to has structural equality.
@@ -787,7 +787,7 @@ Furthermore we require that the value of `C` *has (recursive) structural equalit
787
787
- Nothing else has structural equality.
788
788
789
789
In particular, the value of `C` must be known at pattern-building time (which is pre-monomorphization).
790
-
This means that associated consts cannot be used as patterns.
790
+
This means that associated consts that involve generic parameters cannot be used as patterns.
791
791
792
792
After ensuring all conditions are met, the constant value is translated into a pattern, and now behaves exactly as-if that pattern had been written directly.
793
793
In particular, it fully participates in exhaustiveness checking.
0 commit comments