Skip to content

Commit 4d6c249

Browse files
RexJaeschkeBillWagner
authored andcommitted
Support pattern match Span char on constant string
1 parent cf64a32 commit 4d6c249

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

standard/patterns.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ For a constant pattern `P`, its *converted value* is
157157
Given a pattern input value *e* and a constant pattern `P` with converted value *v*,
158158

159159
- if *e* has integral type or enum type, or a nullable form of one of those, and *v* has integral type, the pattern `P` *matches* the value *e* if result of the expression `e == v` is `true`; otherwise
160+
- if *e* is of type `System.Span<char>` or `System.ReadOnlySpan<char>`, and *v* is a constant string, and *v* does not have a constant value of `null`, then the pattern is considered matching if `System.MemoryExtensions.SequenceEqual<char>(e, System.MemoryExtensions.AsSpan(v))` returns `true`; otherwise
160161
- the pattern `P` *matches* the value *e* if `object.Equals(e, v)` returns `true`.
161162

162163
> *Example*: The `switch` statement in the following method uses five constant patterns in its case labels.

0 commit comments

Comments
 (0)