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; }