SE-0241: Explicit Encoded Offsets for String Indices

I think it would be much better to extend all Collections with the means to get the offset of a given index, and an index at a given offset. Such as:

and a corresponding offset(of: Index) -> Int method as well. Way out of scope for 5.0 at this point.

Reasons I kept this on String.Index:

  1. It's a off-ramp for misuses of encodedOffset which is already on String.Index.
  2. String.Index is an infrequent namespace; if we had to pollute something that will be superseded in the future, better in an infrequent namespace.
  3. It's name wouldn't conflict with a more general addition to all Collections.
1 Like