Runs body
over the content of this string in contiguous memory. If this string is not contiguous, this will first make it contiguous, which will also speed up subsequent access. If this mutates the string, it will invalidate any pre-existing indices.
SDK
- Xcode 11.0+
Framework
- Swift Standard Library
Declaration
Discussion
Note that it is unsafe to escape the pointer provided to body
. For example, strings of up to 15 UTF-8 code units in length may be represented in a small-string representation, and thus will be spilled into temporary stack space which is invalid after with
finishes execution.
Complexity: O(n) if non-contiguous, O(1) if already contiguous