Skip to content
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions standard/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ For a constant pattern `P`, its *converted value* is
Given a pattern input value *e* and a constant pattern `P` with converted value *v*,

- 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
- 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
- the pattern `P` *matches* the value *e* if `object.Equals(e, v)` returns `true`.

> *Example*: The `switch` statement in the following method uses five constant patterns in its case labels.
Expand Down
10 changes: 10 additions & 0 deletions standard/standard-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,15 @@ namespace System

public abstract class FormattableString : IFormattable { }

public static class MemoryExtensions
{
public static ReadOnlySpan<char> AsSpan (this string? text);
public static bool SequenceEqual<T> (this Span<T> span, ReadOnlySpan<T> other)
where T : IEquatable<T>;
public static bool SequenceEqual<T> (this ReadOnlySpan<T> span,
ReadOnlySpan<T> other) where T : IEquatable<T>;
}

public class OperationCanceledException : Exception
{
public OperationCanceledException();
Expand Down Expand Up @@ -1383,6 +1392,7 @@ The following library types are referenced in this specification. The full names
- `global::System.IntPtr`
- `global::System.InvalidCastException`
- `global::System.InvalidOperationException`
- `global::System.MemoryExtensions`
- `global::System.NotSupportedException`
- `global::System.Nullable<T>`
- `global::System.NullReferenceException`
Expand Down
Loading