This is a follow-up to my earlier post, Span, InlineArray and ~Escapable in Practice . Same setup as before: I'm an iOS developer who ported real code onto these types, I built a small package first and wrote this from it, and I'll be honest about where the shipped toolchain and the proposals don't line up yet.
Last time I looked at reading contiguous storage without copies. The two halves I kept hitting after that were the other direction — building a buffer, and parsing text. Building a byte buffer by hand meant Array(unsafeUninitializedCapacity:initializingWith:) with an inout count I had to remember to advance, or a pre-zeroed [UInt8] and an index cursor that nothing checked. Parsing text meant one of two bad choices: copy the String into [UInt8] so I could index bytes, or iterate Character s and pay for grapheme breaking on every byte even when I was looking for an ASCII colon.
OutputSpan (SE-0485) and UTF8Span (SE-0464) are the stdlib's answers.…