mirror of
https://github.com/github/semantic.git
synced 2024-11-25 21:43:07 +03:00
Empty Hashes.
This commit is contained in:
parent
49721679b6
commit
2ab10d6b3d
@ -12,6 +12,11 @@ public enum Hash: AlgebraicHashable {
|
||||
/// The embedding of a raw hash value into an algebraic hash.
|
||||
case Raw(Int)
|
||||
|
||||
/// The empty hash.
|
||||
///
|
||||
/// This is the right and left unit for Unordered.
|
||||
case Empty
|
||||
|
||||
public init(_ label: String, _ hashes: Hash...) {
|
||||
self = .Ordered([ Hash(label) ] + hashes)
|
||||
}
|
||||
@ -57,6 +62,8 @@ public enum Hash: AlgebraicHashable {
|
||||
return s.hashValue
|
||||
case let .Raw(i):
|
||||
return i.hashValue
|
||||
case .Empty:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,6 +78,8 @@ public func == (left: Hash, right: Hash) -> Bool {
|
||||
return a == b
|
||||
case let (.Raw(a), .Raw(b)):
|
||||
return a == b
|
||||
case (.Empty, .Empty):
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user