File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1730,6 +1730,19 @@ extension Array {
1730
1730
return try unsafe body( & inoutBufferPointer)
1731
1731
}
1732
1732
1733
+ @available ( SwiftStdlib 6 . 2 , * )
1734
+ public var mutableSpan : MutableSpan < Element > {
1735
+ @lifetime ( /*inout*/borrow self)
1736
+ @_alwaysEmitIntoClient
1737
+ mutating get {
1738
+ _makeMutableAndUnique ( )
1739
+ let pointer = unsafe _buffer . firstElementAddress
1740
+ let count = _buffer. mutableCount
1741
+ let span = unsafe MutableSpan( _unsafeStart: pointer, count: count)
1742
+ return unsafe _override Lifetime ( span, mutating: & self )
1743
+ }
1744
+ }
1745
+
1733
1746
@inlinable
1734
1747
public __consuming func _copyContents(
1735
1748
initializing buffer: UnsafeMutableBufferPointer < Element >
Original file line number Diff line number Diff line change @@ -1300,6 +1300,18 @@ extension ArraySlice {
1300
1300
return try unsafe body( & inoutBufferPointer)
1301
1301
}
1302
1302
1303
+ @available ( SwiftStdlib 6 . 2 , * )
1304
+ public var mutableSpan : MutableSpan < Element > {
1305
+ @lifetime ( /*inout*/borrow self)
1306
+ @_alwaysEmitIntoClient
1307
+ mutating get {
1308
+ _makeMutableAndUnique ( )
1309
+ let ( pointer, count) = unsafe ( _buffer. firstElementAddress, _buffer. count)
1310
+ let span = unsafe MutableSpan( _unsafeStart: pointer, count: count)
1311
+ return unsafe _override Lifetime ( span, mutating: & self )
1312
+ }
1313
+ }
1314
+
1303
1315
@inlinable
1304
1316
public __consuming func _copyContents(
1305
1317
initializing buffer: UnsafeMutableBufferPointer < Element >
Original file line number Diff line number Diff line change @@ -1242,6 +1242,22 @@ extension ContiguousArray {
1242
1242
return try unsafe body( & inoutBufferPointer)
1243
1243
}
1244
1244
1245
+ @available ( SwiftStdlib 6 . 2 , * )
1246
+ public var mutableSpan : MutableSpan < Element > {
1247
+ @lifetime ( /*inout*/borrow self)
1248
+ @_alwaysEmitIntoClient
1249
+ mutating get {
1250
+ _makeMutableAndUnique ( )
1251
+ // NOTE: We don't have the ability to schedule a call to
1252
+ // ContiguousArrayBuffer.endCOWMutation().
1253
+ // rdar://146785284 (lifetime analysis for end of mutation)
1254
+ let pointer = unsafe _buffer . firstElementAddress
1255
+ let count = _buffer. mutableCount
1256
+ let span = unsafe MutableSpan( _unsafeStart: pointer, count: count)
1257
+ return unsafe _override Lifetime ( span, mutating: & self )
1258
+ }
1259
+ }
1260
+
1245
1261
@inlinable
1246
1262
public __consuming func _copyContents(
1247
1263
initializing buffer: UnsafeMutableBufferPointer < Element >
You can’t perform that action at this time.
0 commit comments