-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: Implement IEnumerator<T> on ref struct enumerators #105276
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime |
I thought "ref structs implementing interfaces" were being postponed/preview for .Net 9(?) |
No, it's planned for C# 13. And this proposal is for .NET 10. |
It sounds to me like it's (at least being set up to be) in preview for C# 13 dotnet/roslyn#73923
That's true 😅 |
That is out of date. |
Welp 😅 |
If only that had been released just a few hours prior 🫠😂 |
Even with interfaces on ref structs, we still can't make ref struct implementing There was long-standing discussion to make an abstraction of non-boxing enumerator. Now ref structs forces everything to be non-boxing. Is there any interest to revisit this area? |
@huoyaoyuan You mean like I think that hasn't happened so far because C#'s generic inference doesn't work on it, forcing the full generics to be typed out, which is less than ideal. |
Yes. But of course if we start to do so, we need also to define an approach to seamless adapt |
Is there a proposal to implement linq operators with TEnumerator? (I think that would be related to #64031 somehow) |
No, we don't plan to do that. |
namespace System
{
public partial static class MemoryExtensions
{
public partial ref struct SpanSplitEnumerator<T> : IEnumerator<Range>
{
}
}
public readonly ref struct ReadOnlySpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
public readonly ref struct Span<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
}
namespace System.Text
{
public partial ref struct SpanLineEnumerator : IEnumerator<ReadOnlySpan<char>>
{
}
public partial ref struct SpanRuneEnumerator : IEnumerator<Rune>
{
}
}
namespace System.Numerics.Tensors
{
public readonly ref struct ReadOnlyTensorSpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
public readonly ref struct TensorSpan<T>
{
public partial ref struct Enumerator : IEnumerator<T>
{
}
}
}
namespace System.Text.RegularExpressions
{
public partial ref struct ValueMatchEnumerator : IEnumerator<ValueMatch>
{
}
public partial ref struct ValueSplitEnumerator : IEnumerator<Range>
{
}
} |
Background and motivation
We've shipped multiple ref struct enumerators. Previously they couldn't implement
IEnumerator<T>
, but now they can. We should have them do so.API Proposal
Notes:
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: