@@ -53,7 +53,10 @@ extension UnsafeTuple {
5353 public var indices : Range < Int > { type. indices }
5454
5555 public func address< T> ( as _: T . Type = T . self) -> UnsafePointer < T > {
56- value. assumingMemoryBound ( to: T . self)
56+ guard type. type == T . self else {
57+ preconditionFailure ( )
58+ }
59+ return value. assumingMemoryBound ( to: T . self)
5760 }
5861
5962 public func address< T> ( of index: Int , as _: T . Type = T . self) -> UnsafePointer < T > {
@@ -109,7 +112,10 @@ extension UnsafeMutableTuple {
109112 public var indices : Range < Int > { type. indices }
110113
111114 public func address< T> ( as _: T . Type = T . self) -> UnsafeMutablePointer < T > {
112- value. assumingMemoryBound ( to: T . self)
115+ guard type. type == T . self else {
116+ preconditionFailure ( )
117+ }
118+ return value. assumingMemoryBound ( to: T . self)
113119 }
114120
115121 public func address< T> ( of index: Int , as _: T . Type = T . self) -> UnsafeMutablePointer < T > {
@@ -119,11 +125,11 @@ extension UnsafeMutableTuple {
119125
120126 public subscript< T > ( ) - > T {
121127 unsafeAddress { UnsafePointer ( address ( as: T . self) ) }
122- unsafeMutableAddress { address ( as: T . self) }
128+ nonmutating unsafeMutableAddress { address ( as: T . self) }
123129 }
124130
125131 public subscript< T > ( _ index: Int) - > T {
126132 unsafeAddress { UnsafePointer ( address ( of: index, as: T . self) ) }
127- unsafeMutableAddress { address ( of: index, as: T . self) }
133+ nonmutating unsafeMutableAddress { address ( of: index, as: T . self) }
128134 }
129135}
0 commit comments