Skip to content

Instantly share code, notes, and snippets.

View tpgmeligmeyling's full-sized avatar

Thomas Gmelig Meyling tpgmeligmeyling

View GitHub Profile
extension KeyValuePairs {
init(elements: [(Key, Value)]) {
func initialize(elements: [(Key, Value)]) -> Self {
typealias Function = ([(Key, Value)]) -> Self
let castedInit = unsafeBitCast(Self.init(dictionaryLiteral:), to: Function.self)
return castedInit(elements)
}
self = initialize(elements: elements)
protocol ComparisonPredicateValue {
var value: Bool? { get }
}
enum ComparisonPredicate<T: Comparable>: ComparisonPredicateValue {
typealias Predicate = ((T, T) -> Bool)
case predicate(lhs: T, rhs: T, Predicate)