mirror of
https://github.com/apple/swift-collections
synced 2026-11-29 05:14:20 +00:00
Add subscript requirements to [Mutable]Container with borrow/mutate accessors
This commit is contained in:
11 files changed
+59
-41
No files matched your search
@@ -41,7 +41,7 @@ extension RigidArray: BidirectionalContainer where Element: ~Copyable {}
|
||||
extension RigidArray: RandomAccessContainer where Element: ~Copyable {}
|
||||
|
||||
#if compiler(>=6.4)
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@available(SwiftStdlib 5.0, *)
|
||||
extension RigidArray: MutableContainer where Element: ~Copyable {}
|
||||
|
||||
@available(SwiftStdlib 6.4, *)
|
||||
@@ -153,12 +153,14 @@ extension RigidArray where Element: ~Copyable {
|
||||
@inlinable
|
||||
public subscript(position: Int) -> Element {
|
||||
@inline(__always)
|
||||
unsafeAddress {
|
||||
_ptr(to: position)
|
||||
@_unsafeSelfDependentResult
|
||||
borrow {
|
||||
_ptr(to: position).pointee
|
||||
}
|
||||
@inline(__always)
|
||||
unsafeMutableAddress {
|
||||
_mutablePtr(to: position)
|
||||
@_unsafeSelfDependentResult
|
||||
mutate {
|
||||
&_mutablePtr(to: position).pointee
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user