Confused by String Iteration performance

You should also consider checking out Piercing the String Veil to help provide further clarity on the various String representations. Note that the above reference to "contiguous UTF-8" is important: a String will be opaque if it is incapable of providing a pointer to contiguous UTF-8 bytes. It doesn't matter which of those two constraints it can't satisfy: it may store contiguous UTF-16 bytes, or it may store discontiguous UTF-8, either will force the String type to be opaque.

1 Like