-
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
Add more AsSpan overloads to StringSegment #50428
Comments
Tagging subscribers to this area: @GrabYourPitchforks, @carlossanlop Issue DetailsBackground and MotivationMany classes provide The Proposed APInamespace Microsoft.Extensions.Primitives
{
public readonly struct StringSegment : IEquatable<StringSegment>, IEquatable<string>
{
public ReadOnlySpan<char> AsSpan();
+ public ReadOnlySpan<char> AsSpan(int start);
+ public ReadOnlySpan<char> AsSpan(int start, int length);
}
} Usage Examples// input.AsSpan().Slice(startIndex, typeLength);
input.AsSpan(startIndex, typeLength); Alternative DesignsNo, other classes that provide RisksNone
|
Tagging subscribers to this area: @eerhardt, @maryamariyan Issue DetailsBackground and MotivationMany classes provide The Proposed APInamespace Microsoft.Extensions.Primitives
{
public readonly struct StringSegment : IEquatable<StringSegment>, IEquatable<string>
{
public ReadOnlySpan<char> AsSpan();
+ public ReadOnlySpan<char> AsSpan(int start);
+ public ReadOnlySpan<char> AsSpan(int start, int length);
}
} Usage Examples// input.AsSpan().Slice(startIndex, typeLength);
input.AsSpan(startIndex, typeLength); Alternative DesignsNo, other classes that provide RisksNone
|
Looks good as proposed. namespace Microsoft.Extensions.Primitives
{
partial struct StringSegment : IEquatable<StringSegment>, IEquatable<string>
{
public ReadOnlySpan<char> AsSpan(int start);
public ReadOnlySpan<char> AsSpan(int start, int length);
}
} |
I'd like to add these overloads. |
Background and Motivation
Many classes provide
AsSpan
methods and most provide at least the 3 basic methods,AsSpan()
,AsSpan(int start)
,AsSpan(int start, int length)
.The
StringSegment
class only providesAsSpan()
, but it should provide the other two for consistency and ease of use.Proposed API
Usage Examples
Alternative Designs
No, other classes that provide
AsSpan
have similar overloadsRisks
None
The text was updated successfully, but these errors were encountered: