mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* Support swift-syntax from 600.0.0-latest The Xcode 16 beta generates macro projects using these swift-syntax snapshots. Luckily things seem to be backwards compatible, so we can expand our supported range. * wip
38 lines
915 B
Swift
38 lines
915 B
Swift
@_spi(Reflection) import CasePaths
|
|
|
|
extension PresentationState {
|
|
var id: PresentationID? {
|
|
self.wrappedValue.map(PresentationID.init(base:))
|
|
}
|
|
}
|
|
|
|
struct PresentationID: Hashable, Identifiable {
|
|
private let identifier: AnyHashable?
|
|
private let tag: UInt32?
|
|
private let type: Any.Type
|
|
|
|
init<Base>(base: Base) {
|
|
self.tag = EnumMetadata(Base.self)?.tag(of: base)
|
|
if let id = _identifiableID(base) ?? EnumMetadata.project(base).flatMap(_identifiableID) {
|
|
self.identifier = id
|
|
} else {
|
|
self.identifier = nil
|
|
}
|
|
self.type = Base.self
|
|
}
|
|
|
|
var id: Self { self }
|
|
|
|
static func == (lhs: Self, rhs: Self) -> Bool {
|
|
lhs.identifier == rhs.identifier
|
|
&& lhs.tag == rhs.tag
|
|
&& lhs.type == rhs.type
|
|
}
|
|
|
|
func hash(into hasher: inout Hasher) {
|
|
hasher.combine(self.identifier)
|
|
hasher.combine(self.tag)
|
|
hasher.combine(ObjectIdentifier(self.type))
|
|
}
|
|
}
|