mirror of
https://github.com/github/semantic.git
synced 2024-11-29 21:52:59 +03:00
🔥 AnyEquatable.
This commit is contained in:
parent
939a714807
commit
1059a00db0
@ -22,7 +22,6 @@
|
||||
D4413FF11BB08FDC00E3C3C1 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4413FF01BB08FDC00E3C3C1 /* JSON.swift */; };
|
||||
D45A36C91BBC667D00BE3DDE /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = D45A36C81BBC667D00BE3DDE /* Category.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D45A36CD1BBC75DF00BE3DDE /* Info.swift in Sources */ = {isa = PBXBuildFile; fileRef = D45A36CC1BBC75DF00BE3DDE /* Info.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D49FCBAD1BBD7A3100C5E9C3 /* AnyEquatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49FCBAC1BBD7A3100C5E9C3 /* AnyEquatable.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D49FCBC21BBEF2C600C5E9C3 /* Fix.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49FCBC11BBEF2C600C5E9C3 /* Fix.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D49FCBC41BBEF98E00C5E9C3 /* Free.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49FCBC31BBEF98E00C5E9C3 /* Free.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D49FCBC61BBF214300C5E9C3 /* Patch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49FCBC51BBF214300C5E9C3 /* Patch.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
@ -102,7 +101,6 @@
|
||||
D4413FF01BB08FDC00E3C3C1 /* JSON.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JSON.swift; sourceTree = "<group>"; };
|
||||
D45A36C81BBC667D00BE3DDE /* Category.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = "<group>"; };
|
||||
D45A36CC1BBC75DF00BE3DDE /* Info.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Info.swift; sourceTree = "<group>"; };
|
||||
D49FCBAC1BBD7A3100C5E9C3 /* AnyEquatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyEquatable.swift; sourceTree = "<group>"; };
|
||||
D49FCBC11BBEF2C600C5E9C3 /* Fix.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Fix.swift; sourceTree = "<group>"; };
|
||||
D49FCBC31BBEF98E00C5E9C3 /* Free.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Free.swift; sourceTree = "<group>"; };
|
||||
D49FCBC51BBF214300C5E9C3 /* Patch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Patch.swift; sourceTree = "<group>"; };
|
||||
@ -209,7 +207,6 @@
|
||||
D4D7F3161BBB22E500AAB0C0 /* Hash.swift */,
|
||||
D45A36C81BBC667D00BE3DDE /* Category.swift */,
|
||||
D45A36CC1BBC75DF00BE3DDE /* Info.swift */,
|
||||
D49FCBAC1BBD7A3100C5E9C3 /* AnyEquatable.swift */,
|
||||
D49FCBC11BBEF2C600C5E9C3 /* Fix.swift */,
|
||||
D49FCBC31BBEF98E00C5E9C3 /* Free.swift */,
|
||||
D49FCBC51BBF214300C5E9C3 /* Patch.swift */,
|
||||
@ -403,7 +400,6 @@
|
||||
D432D4731BA9C55300F3FABC /* Stream.swift in Sources */,
|
||||
D49FCBC61BBF214300C5E9C3 /* Patch.swift in Sources */,
|
||||
D4AAE5421B5AE2D0004E581F /* Doc.swift in Sources */,
|
||||
D49FCBAD1BBD7A3100C5E9C3 /* AnyEquatable.swift in Sources */,
|
||||
D45A36CD1BBC75DF00BE3DDE /* Info.swift in Sources */,
|
||||
D4AAE5461B5AE2D0004E581F /* Parse.swift in Sources */,
|
||||
D49FCBC81BBF2C4300C5E9C3 /* Algorithm.swift in Sources */,
|
||||
|
@ -1,20 +0,0 @@
|
||||
/// 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<T>] and then comparing with ==.
|
||||
public enum AnyEquatable<A>: Equatable {
|
||||
case External(A, (A, A) -> Bool)
|
||||
|
||||
public var value: A {
|
||||
switch self {
|
||||
case let .External(a, _):
|
||||
return a
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func == <A> (left: AnyEquatable<A>, right: AnyEquatable<A>) -> Bool {
|
||||
switch (left, right) {
|
||||
case let (.External(a, eq), .External(b, _)):
|
||||
return eq(a, b)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user