File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1730,6 +1730,22 @@ extension Array {
17301730 return try unsafe body( & inoutBufferPointer)
17311731 }
17321732
1733+ @available ( SwiftStdlib 6 . 2 , * )
1734+ public var mutableSpan : MutableSpan < Element > {
1735+ @lifetime ( /*inout*/borrow self)
1736+ @_alwaysEmitIntoClient
1737+ mutating get {
1738+ _makeMutableAndUnique ( )
1739+ // NOTE: We don't have the ability to schedule a call to
1740+ // ContiguousArrayBuffer.endCOWMutation().
1741+ // rdar://146785284 (lifetime analysis for end of mutation)
1742+ let pointer = unsafe _buffer . firstElementAddress
1743+ let count = _buffer. mutableCount
1744+ let span = unsafe MutableSpan( _unsafeStart: pointer, count: count)
1745+ return unsafe _override Lifetime ( span, mutating: & self )
1746+ }
1747+ }
1748+
17331749 @inlinable
17341750 public __consuming func _copyContents(
17351751 initializing buffer: UnsafeMutableBufferPointer < Element >
Original file line number Diff line number Diff line change @@ -1300,6 +1300,21 @@ extension ArraySlice {
13001300 return try unsafe body( & inoutBufferPointer)
13011301 }
13021302
1303+ @available ( SwiftStdlib 6 . 2 , * )
1304+ public var mutableSpan : MutableSpan < Element > {
1305+ @lifetime ( /*inout*/borrow self)
1306+ @_alwaysEmitIntoClient
1307+ mutating get {
1308+ _makeMutableAndUnique ( )
1309+ // NOTE: We don't have the ability to schedule a call to
1310+ // ContiguousArrayBuffer.endCOWMutation().
1311+ // rdar://146785284 (lifetime analysis for end of mutation)
1312+ let ( pointer, count) = unsafe ( _buffer. firstElementAddress, _buffer. count)
1313+ let span = unsafe MutableSpan( _unsafeStart: pointer, count: count)
1314+ return unsafe _override Lifetime ( span, mutating: & self )
1315+ }
1316+ }
1317+
13031318 @inlinable
13041319 public __consuming func _copyContents(
13051320 initializing buffer: UnsafeMutableBufferPointer < Element >
Original file line number Diff line number Diff line change @@ -1242,6 +1242,22 @@ extension ContiguousArray {
12421242 return try unsafe body( & inoutBufferPointer)
12431243 }
12441244
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+
12451261 @inlinable
12461262 public __consuming func _copyContents(
12471263 initializing buffer: UnsafeMutableBufferPointer < Element >
You can’t perform that action at this time.
0 commit comments