/// An Equatable instance for any type for which you can provide an equality function. /// /// This can enable equating [T] where T does not conform to Equatable, by first mapping to [AnyEquatable] and then comparing with ==. public enum AnyEquatable: Equatable { case External(A, (A, A) -> Bool) public var value: A { switch self { case let .External(a, _): return a } } } public func == (left: AnyEquatable, right: AnyEquatable) -> Bool { switch (left, right) { case let (.External(a, eq), .External(b, _)): return eq(a, b) } }