-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Labels
feature request 📬A request for new changes to improve functionalityA request for new changes to improve functionality
Description
Overview
This would allow ref structs to be used in pattern matching with a ThrowHelper
case, using the new allow ref struct "anti-constraint".
API breakdown
This changes nothing except allowable use cases for existing ThrowHelper APIs.
Usage example
This use case has nothing specific in mind, but the point is you can imagine pattern matching a ref struct
such as Span<T>
.
Span<int> span = x switch
{
0 => stackalloc int[size],
1 => new int[size],
2 => something.AsSpan(),
_ => ThrowHelper.ThrowArgumentOutOfRangeException<Span<int>>(),
};
Breaking change?
No
Alternatives
throw without ThrowHelper
Additional context
This will require .NET 9 and C# version 13
Help us help you
Yes, I'd like to be assigned to work on this item
Metadata
Metadata
Assignees
Labels
feature request 📬A request for new changes to improve functionalityA request for new changes to improve functionality