Reduce Swift version requirement to 5.7

This commit is contained in:
Guoye Zhang committed 2023-07-06 22:52:11 -07:00
1 parent ae848811f9
commit 885b94bd13
5 files changed
+23 -5

No files matched your search

+4
View File
@@ -32,7 +32,11 @@ struct ISOLatin1String: Sendable, Hashable {
try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: self._storage.unicodeScalars.count) { buffer in
for (index, scalar) in self._storage.unicodeScalars.enumerated() {
assert(scalar.value <= UInt8.max)
#if swift(>=5.8)
buffer.initializeElement(at: index, to: UInt8(truncatingIfNeeded: scalar.value))
#else
buffer[index] = UInt8(truncatingIfNeeded: scalar.value)
#endif
}
return try body(UnsafeBufferPointer(buffer))
}