Swiftgram / TDLibKit

Native Swift wrapper for Telegram's TDLib. Available on iOS, macOS, watchOS, tvOS and visionOS.
MIT License
101 stars 23 forks source link

Data types conform to `Hashable` and `Identifiable`? #26

Closed laosb closed 1 year ago

laosb commented 1 year ago

When integrating with SwiftUI, it would be very helpful if data types like StickerSetInfo and File conform to Hashable, and for data types with an id field, also conform to Identifiable.

As a example: The new SwiftUI NavigationLink value + .navigationDestination initializer requires the value conforms to Hashable, and in ForEach and List, you can save the use of key: when elements conform to Identifiable.

Considering automatic synthesis of Hashable requirements is only available when declared in the same file, it will be a very tedious job of "implementing" a hash(into:) which basically manually hasher.combine() every field, if I want to achieve Hashable conformance without changing TDLibKit.

Kylmakalle commented 1 year ago

Added in https://github.com/Swiftgram/TDLibKit/pull/32