[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/kidoz/dotpython/main/src/DotPython.Language/Text/TextSpan.cs [Back]  [Original]

namespace DotPython.Language.Text;

public readonly record struct TextSpan
{
    public TextSpan(int start, int length)
    {
        ArgumentOutOfRangeException.ThrowIfNegative(start);
        ArgumentOutOfRangeException.ThrowIfNegative(length);

        Start = start;
        Length = length;
    }

    public int Start { get; }

    public int Length { get; }

    public int End => checked(Start + Length);

    public static TextSpan FromBounds(int start, int end)
    {
        ArgumentOutOfRangeException.ThrowIfLessThan(end, start);
        return new TextSpan(start, end - start);
    }

    public bool Contains(int position) => position >= Start && position < End;
}

Web Proxy Viewer  |  New URL  |  Original Page