Skip to content

Commit eace6a6

Browse files
committed
_SwiftNativeFoundationType: Add hash(into:) requirement with a default implementation
1 parent 22a7465 commit eace6a6

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

Foundation/Boxing.swift

+6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ internal protocol _SwiftNativeFoundationType : class {
7575

7676
func mutableCopy(with zone : NSZone) -> Any
7777

78+
func hash(into hasher: inout Hasher)
7879
var hashValue: Int { get }
80+
7981
var description: String { get }
8082
var debugDescription: String { get }
8183

@@ -115,6 +117,10 @@ extension _SwiftNativeFoundationType {
115117
return _mapUnmanaged { ($0 as NSObject).mutableCopy() }
116118
}
117119

120+
func hash(into hasher: inout Hasher) {
121+
_mapUnmanaged { hasher.combine($0) }
122+
}
123+
118124
var hashValue: Int {
119125
return _mapUnmanaged { return $0.hashValue }
120126
}

TestFoundation/TestDateInterval.swift

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// TestDateInterval.swift
3+
// TestFoundation
4+
//
5+
// Created by Karoly Lorentey on 2019-04-10.
6+
// Copyright © 2019 Apple. All rights reserved.
7+
//
8+
9+
import Foundation

TestFoundation/TestMeasurement.swift

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// TestMeasurement.swift
3+
// TestFoundation
4+
//
5+
// Created by Karoly Lorentey on 2019-04-10.
6+
// Copyright © 2019 Apple. All rights reserved.
7+
//
8+
9+
import Foundation

0 commit comments

Comments
 (0)