File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -5967,7 +5967,7 @@ elif Self == 'Dictionary':
5967
5967
5968
5968
${SubscriptingWithIndexDoc}
5969
5969
@_fixed_layout // FIXME(sil-serialize-all)
5970
- public struct Index : Comparable {
5970
+ public struct Index : Comparable, Hashable {
5971
5971
// Index for native buffer is efficient. Index for bridged NS${Self} is
5972
5972
// not, because neither NSEnumerator nor fast enumeration support moving
5973
5973
// backwards. Even if they did, there is another issue: NSEnumerator does
@@ -6089,6 +6089,22 @@ extension ${Self}.Index {
6089
6089
#endif
6090
6090
}
6091
6091
}
6092
+
6093
+ @_inlineable // FIXME(sil-serialize-all)
6094
+ public var hashValue: Int {
6095
+ if _fastPath(_guaranteedNative) {
6096
+ return _nativeIndex.offset
6097
+ }
6098
+
6099
+ switch _value {
6100
+ case ._native(let nativeIndex):
6101
+ return nativeIndex.offset
6102
+ #if _runtime(_ObjC)
6103
+ case ._cocoa(let cocoaIndex):
6104
+ return cocoaIndex.currentKeyIndex
6105
+ #endif
6106
+ }
6107
+ }
6092
6108
}
6093
6109
6094
6110
#if _runtime(_ObjC)
Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ extension String.Index : Comparable {
67
67
}
68
68
}
69
69
70
+ extension String . Index : Hashable {
71
+ @_inlineable // FIXME(sil-serialize-all)
72
+ public var hashValue : Int {
73
+ return _compoundOffset. hashValue
74
+ }
75
+ }
76
+
70
77
extension String . Index {
71
78
internal typealias _Self = String . Index
72
79
You can’t perform that action at this time.
0 commit comments