-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Extensions-Primitives
Milestone
Description
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 provides AsSpan(), but it should provide the other two for consistency and ease of use.
Proposed API
namespace 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 Designs
No, other classes that provide AsSpan have similar overloads
Risks
None
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-Extensions-Primitives