假设我们有以下结构,它围绕一个闭包:
public struct Task: Hashable {
pubic var closure: RateLimitedClosure
public var hashValue: Int {
// return unique hash
return 1
}
public static func ==(lhs: Task, rhs: Task) -> Bool {
return lhs.hashValue == rhs.hashValue
}
}
==
如果闭包完全相同,我想要函数返回true。
然后我可以使用这个结构作为字典的键,声明如下:
var dict = [Task, (Date, RateLimitedClosure)]