What is the meaning of Swift.String.Index(_rawBits: )

Viewed 704

I am trying to understand what does _rawBits really mean in Swift.String.Index(_rawBits:). If you print a String.Index, you get something like Swift.String.Index(_rawBits: 983040). But what does that really mean?

Can I (mathematically) calculate the actual index in a string using this rawBits number at all? either base 32, 16, or whatever else?

Swift Range uses String.Index as its upper and lower bounds.

1 Answers

Swift Range uses String.Index as its upper and lower bounds.`

No, it doesn't. Range<String.Index> does, but that's only one particular type of Range, which is otherwise generic over a type variable called Bound.

The _rawBits are an internal implementation detail of the string indices. You should treat them as an opaque type, that you can only manipulate using the corresponding index apis on String, Substring and friends.

Related