mirror of
https://github.com/gosticks/SwiftGit2.git
synced 2025-10-16 11:55:34 +00:00
Refactor Equatable implementations on ReferenceType and PointerType
This commit is contained in:
parent
778596b71a
commit
743083d19d
@ -17,11 +17,12 @@ public protocol PointerType: Hashable {
|
||||
var type: git_otype { get }
|
||||
}
|
||||
|
||||
public func == <P: PointerType>(lhs: P, rhs: P) -> Bool {
|
||||
return lhs.oid == rhs.oid && lhs.type.rawValue == rhs.type.rawValue
|
||||
}
|
||||
|
||||
public extension PointerType {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.oid == rhs.oid
|
||||
&& lhs.type == rhs.type
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(oid)
|
||||
}
|
||||
|
||||
@ -20,12 +20,12 @@ public protocol ReferenceType {
|
||||
var oid: OID { get }
|
||||
}
|
||||
|
||||
public func ==<T: ReferenceType>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
public extension ReferenceType {
|
||||
static func == (lhs: Self, rhs: Self) -> Bool {
|
||||
return lhs.longName == rhs.longName
|
||||
&& lhs.oid == rhs.oid
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(longName)
|
||||
hasher.combine(oid)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user