mirror of
https://github.com/github/semantic.git
synced 2025-01-04 13:34:31 +03:00
AnyHashable.
This commit is contained in:
parent
18d74a9d9c
commit
a2a55531c9
@ -21,6 +21,7 @@
|
||||
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 = (); }; };
|
||||
D49C2CA41BBD72E300949127 /* AnyHashable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D49C2CA31BBD72E300949127 /* AnyHashable.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D4A71DC51BB45B850051416D /* Vertex.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A71DC41BB45B850051416D /* Vertex.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D4A71DC71BB4AC9E0051416D /* VertexTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4A71DC61BB4AC9E0051416D /* VertexTests.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
D4AAE50E1B5AE22E004E581F /* Doubt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D4AAE4FD1B5AE22E004E581F /* Doubt.framework */; };
|
||||
@ -98,6 +99,7 @@
|
||||
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>"; };
|
||||
D49C2CA31BBD72E300949127 /* AnyHashable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnyHashable.swift; sourceTree = "<group>"; };
|
||||
D4A71DC41BB45B850051416D /* Vertex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vertex.swift; sourceTree = "<group>"; };
|
||||
D4A71DC61BB4AC9E0051416D /* VertexTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VertexTests.swift; sourceTree = "<group>"; };
|
||||
D4AAE4FD1B5AE22E004E581F /* Doubt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Doubt.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -205,6 +207,7 @@
|
||||
D4D7F3161BBB22E500AAB0C0 /* Hash.swift */,
|
||||
D45A36C81BBC667D00BE3DDE /* Category.swift */,
|
||||
D45A36CC1BBC75DF00BE3DDE /* Info.swift */,
|
||||
D49C2CA31BBD72E300949127 /* AnyHashable.swift */,
|
||||
D4AAE5001B5AE22E004E581F /* Supporting Files */,
|
||||
);
|
||||
path = Doubt;
|
||||
@ -392,6 +395,7 @@
|
||||
D4AAE54A1B5AE2D0004E581F /* Syntax.swift in Sources */,
|
||||
D432D4731BA9C55300F3FABC /* Stream.swift in Sources */,
|
||||
D4AAE5421B5AE2D0004E581F /* Doc.swift in Sources */,
|
||||
D49C2CA41BBD72E300949127 /* AnyHashable.swift in Sources */,
|
||||
D432D4771BA9FE6A00F3FABC /* Comparable.swift in Sources */,
|
||||
D45A36CD1BBC75DF00BE3DDE /* Info.swift in Sources */,
|
||||
D4AAE5461B5AE2D0004E581F /* Parse.swift in Sources */,
|
||||
|
17
prototype/Doubt/AnyHashable.swift
Normal file
17
prototype/Doubt/AnyHashable.swift
Normal file
@ -0,0 +1,17 @@
|
||||
public enum AnyHashable<A>: Hashable {
|
||||
case External(A, (A, A) -> Bool, A -> Int)
|
||||
|
||||
public var hashValue: Int {
|
||||
switch self {
|
||||
case let .External(a, _, hash):
|
||||
return hash(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func == <A> (left: AnyHashable<A>, right: AnyHashable<A>) -> Bool {
|
||||
switch (left, right) {
|
||||
case let (.External(a, eq, _), .External(b, _, _)):
|
||||
return eq(a, b)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user