It would be nice if Spans conformed to Collection. If we did that, AttributedRope.Runs could also be a Collection, and we could replace r.getAttributes(at: r(after: r.startIndex)) with r.runs[r.index(after: r.startIndex)].attributes which is the same API that AttributedString uses.
We could take inspiration from the design of AttributedString.Runs for both Spans and AttributedRope.Runs.
Specifically:
You can subscript into Spans using Spans.Index or BTreeNode<SpansSummary>.Index.
Spans would be a collection of Span, and its index would be Spans.Index. Doing spans.index(spans.startIndex, offsetBy: 10) would get you an index pointing to the 10th Span.
Using a BTreeNode<SpansSummary>.Index to index into a Spans would give you the Span that covers BTreeNode<SpansSummary<T>>.Index.position, if it exists.
It would be nice if Spans conformed to Collection. If we did that, AttributedRope.Runs could also be a Collection, and we could replace
r.getAttributes(at: r(after: r.startIndex))
withr.runs[r.index(after: r.startIndex)].attributes
which is the same API that AttributedString uses.We could take inspiration from the design of AttributedString.Runs for both Spans and AttributedRope.Runs.
Specifically:
spans.index(spans.startIndex, offsetBy: 10)
would get you an index pointing to the 10th SpanBTreeNode<SpansSummary<T>>.Index.position
, if it exists.