Created
January 8, 2021 10:03
-
-
Save haifengkao/a15d3a02d8a1101ad91303a75b8f66d4 to your computer and use it in GitHub Desktop.
TaggedWeakCanBePutToEnum.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct TaggedWeak<T: AnyObject, Hash: Hashable>: Hashable { | |
public static func == (lhs: TaggedWeak<T, Hash>, rhs: TaggedWeak<T, Hash>) -> Bool { | |
lhs.hash == rhs.hash | |
} | |
public func hash(into hasher: inout Hasher) { | |
hasher.combine(hash) | |
} | |
public weak var value: T? | |
let hash: Hash | |
public init(hash: Hash, _ value: T?) { | |
self.value = value | |
self.hash = hash | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment