Getting a span out of a String should not be this hard
Swift Forums
Getting a span out of a String should not be this hard
Currently to get a UnsafeBufferPointer or Span out of a String without requiring too high of a platforms requirement, you need code similar to the following for maximum performance: @available(SwiftStdlib 5.1, *) extension String { /// Calls `body` with a `Span` of this String's utf8 bytes. @inlinable @inline(always) func withSpan_Compatibility<T>( _ body: (Span<UInt8>) -> T ) -> T { /// Fast path: Currently always the case for non-Darwin. /// On Darw...
0 comments
No comments yet.