@@ -1173,7 +1173,7 @@ extension JSONDecoding.UnkeyedContainer: UnkeyedDecodingContainer {
1173
1173
}
1174
1174
1175
1175
@inline ( __always)
1176
- mutating func _getOrThrow( ) throws -> ( index: any CodingKey , value: JSONMapValue ) {
1176
+ mutating func _getOrThrow( ) throws -> ( index: _CodingKey , value: JSONMapValue ) {
1177
1177
let idx = currentIndex
1178
1178
guard !isAtEnd else {
1179
1179
throw DecodingError . valueNotFound (
@@ -1314,3 +1314,40 @@ extension JSONDecoding.UnkeyedContainer: UnkeyedDecodingContainer {
1314
1314
self . _currMapIdx = array. startIndex
1315
1315
}
1316
1316
}
1317
+
1318
+ // Compatibility shim for SE-0370
1319
+ #if swift(<5.8)
1320
+ extension UnsafeMutableBufferPointer {
1321
+ fileprivate func initialize(
1322
+ fromContentsOf source: some Collection < Element >
1323
+ ) -> Index {
1324
+ let count = source. withContiguousStorageIfAvailable {
1325
+ guard let sourceAddress = $0. baseAddress, !$0. isEmpty else {
1326
+ return 0
1327
+ }
1328
+ precondition (
1329
+ $0. count <= self . count,
1330
+ " buffer cannot contain every element from source. "
1331
+ )
1332
+ baseAddress? . initialize ( from: sourceAddress, count: $0. count)
1333
+ return $0. count
1334
+ }
1335
+ if let count {
1336
+ return startIndex. advanced ( by: count)
1337
+ }
1338
+
1339
+ var ( iterator, copied) = self . initialize ( from: source)
1340
+ precondition (
1341
+ iterator. next ( ) == nil ,
1342
+ " buffer cannot contain every element from source. "
1343
+ )
1344
+ return startIndex. advanced ( by: copied)
1345
+ }
1346
+
1347
+ fileprivate func initializeElement( at index: Index , to value: Element ) {
1348
+ precondition ( startIndex <= index && index < endIndex)
1349
+ let p = baseAddress!. advanced ( by: index)
1350
+ p. initialize ( to: value)
1351
+ }
1352
+ }
1353
+ #endif
0 commit comments