Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AnyHashableSendable
ergonomics (#47)
* `AnyHashableSendable` ergonomics While working with this type I noticed a couple deficiencies: - First, the initializer takes an opaque type rather than an existential, and while existentials are typically automatically opened, there are cases in which this initializer will fail, _e.g._: ```swift let x: (any Hashable & Sendable)? x.map(AnyHashableSendable.init) // 🛑 ``` We can fix this by updating the initializer to be an `any` already. - Second, comparing an `AnyHashableSendable` with another `AnyHashable` fails because of the underlying type, but there is an underscored public protocol in the standard library we can take advantage of that is called when a hashable type is cast to `AnyHashable`, and if we return the base value then things like this start to work: ```swift AnyHashableSendable(1) == 1 as AnyHashable // true ``` * Add basic literals * fix * fix
- Loading branch information