File tree Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Expand file tree Collapse file tree 3 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -1427,6 +1427,25 @@ extension Array: RangeReplaceableCollection {
1427
1427
return try unsafe body( bufferPointer)
1428
1428
}
1429
1429
}
1430
+
1431
+ @available ( SwiftStdlib 6 . 2 , * )
1432
+ public var span : Span < Element > {
1433
+ @lifetime ( borrow self)
1434
+ @_alwaysEmitIntoClient
1435
+ borrowing get {
1436
+ #if _runtime(_ObjC)
1437
+ if _slowPath ( !_buffer. _isNative) {
1438
+ let buffer = _buffer. getOrAllocateAssociatedObjectBuffer ( )
1439
+ let ( pointer, count) = ( buffer. firstElementAddress, buffer. count)
1440
+ let span = Span ( _unsafeStart: pointer, count: count)
1441
+ return _overrideLifetime ( span, borrowing: self )
1442
+ }
1443
+ #endif
1444
+ let ( pointer, count) = ( _buffer. firstElementAddress, _buffer. count)
1445
+ let span = Span ( _unsafeStart: pointer, count: count)
1446
+ return _overrideLifetime ( span, borrowing: self )
1447
+ }
1448
+ }
1430
1449
1431
1450
@inlinable
1432
1451
public __consuming func _copyToContiguousArray( ) -> ContiguousArray < Element > {
Original file line number Diff line number Diff line change 2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -1116,6 +1116,17 @@ extension ArraySlice: RangeReplaceableCollection {
1116
1116
}
1117
1117
}
1118
1118
1119
+ @available ( SwiftStdlib 6 . 2 , * )
1120
+ public var span : Span < Element > {
1121
+ @lifetime ( borrow self)
1122
+ @_alwaysEmitIntoClient
1123
+ borrowing get {
1124
+ let ( pointer, count) = ( _buffer. firstElementAddress, _buffer. count)
1125
+ let span = Span ( _unsafeStart: pointer, count: count)
1126
+ return _overrideLifetime ( span, borrowing: self )
1127
+ }
1128
+ }
1129
+
1119
1130
@inlinable
1120
1131
public __consuming func _copyToContiguousArray( ) -> ContiguousArray < Element > {
1121
1132
if let n = _buffer. requestNativeBuffer ( ) {
Original file line number Diff line number Diff line change 2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -1021,6 +1021,17 @@ extension ContiguousArray: RangeReplaceableCollection {
1021
1021
}
1022
1022
}
1023
1023
1024
+ @available ( SwiftStdlib 6 . 2 , * )
1025
+ public var span : Span < Element > {
1026
+ @lifetime ( borrow self)
1027
+ @_alwaysEmitIntoClient
1028
+ borrowing get {
1029
+ let ( pointer, count) = ( _buffer. firstElementAddress, _buffer. count)
1030
+ let span = Span ( _unsafeStart: pointer, count: count)
1031
+ return _overrideLifetime ( span, borrowing: self )
1032
+ }
1033
+ }
1034
+
1024
1035
@inlinable
1025
1036
public __consuming func _copyToContiguousArray( ) -> ContiguousArray < Element > {
1026
1037
if let n = _buffer. requestNativeBuffer ( ) {
You can’t perform that action at this time.
0 commit comments