File tree Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import Foundation
9
9
10
- struct AnyHashableData : Hashable {
11
- private let value : Any
12
- private let hashValueFunc : ( ) -> Int
13
- private let equalsFunc : ( Any ) -> Bool
14
-
15
- init < T: Hashable > ( _ value: T ) {
16
- self . value = value
17
- self . hashValueFunc = { value. hashValue }
18
- self . equalsFunc = { ( $0 as? T ) == value }
19
- }
20
-
21
- static func == ( lhs: AnyHashableData , rhs: AnyHashableData ) -> Bool {
22
- return lhs. equalsFunc ( rhs. value)
23
- }
24
-
25
- func hash( into hasher: inout Hasher ) {
26
- hasher. combine ( hashValueFunc ( ) )
27
- }
28
-
29
- var description : String {
30
- return String ( describing: value)
31
- }
32
- }
33
-
34
10
struct NoExtraData : Hashable { }
35
11
36
12
struct CacheKey : Hashable {
37
13
let uri : String
38
14
let requestType : String
39
- let extraData : AnyHashableData ?
15
+ let extraData : AnyHashable ?
40
16
41
- init < ExtraData : Hashable > ( uri: String , requestType: String , extraData: ExtraData ? = nil ) {
17
+ init ( uri: String , requestType: String , extraData: AnyHashable ? = nil ) {
42
18
self . uri = uri
43
19
self . requestType = requestType
44
- self . extraData = extraData. map ( AnyHashableData . init )
20
+ self . extraData = extraData
45
21
}
46
22
47
23
static func == ( lhs: CacheKey , rhs: CacheKey ) -> Bool {
You can’t perform that action at this time.
0 commit comments