mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-25 20:55:03 +08:00
Move Equatable conformances to static funcs (#746)
This commit is contained in:
@@ -8,14 +8,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct RepositoryDetails: Codable, Equatable {
|
||||
struct RepositoryDetails: Codable {
|
||||
let owner: String
|
||||
let name: String
|
||||
let hasIssuesEnabled: Bool
|
||||
}
|
||||
|
||||
func == (lhs: RepositoryDetails, rhs: RepositoryDetails) -> Bool {
|
||||
return lhs.owner == rhs.owner &&
|
||||
lhs.name == rhs.name &&
|
||||
lhs.hasIssuesEnabled == rhs.hasIssuesEnabled
|
||||
extension RepositoryDetails: Equatable {
|
||||
static func == (lhs: RepositoryDetails, rhs: RepositoryDetails) -> Bool {
|
||||
return lhs.owner == rhs.owner &&
|
||||
lhs.name == rhs.name &&
|
||||
lhs.hasIssuesEnabled == rhs.hasIssuesEnabled
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum SearchQuery: Codable, Equatable {
|
||||
enum SearchQuery: Codable {
|
||||
case search(String), recentlyViewed(RepositoryDetails)
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
@@ -44,13 +44,15 @@ enum SearchQuery: Codable, Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
func == (lhs: SearchQuery, rhs: SearchQuery) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (let .search(lhsText), let .search(rhsText)):
|
||||
return lhsText == rhsText
|
||||
case (let .recentlyViewed(lhsRepo), let .recentlyViewed(rhsRepo)):
|
||||
return lhsRepo == rhsRepo
|
||||
default:
|
||||
return false
|
||||
extension SearchQuery: Equatable {
|
||||
static func == (lhs: SearchQuery, rhs: SearchQuery) -> Bool {
|
||||
switch (lhs, rhs) {
|
||||
case (let .search(lhsText), let .search(rhsText)):
|
||||
return lhsText == rhsText
|
||||
case (let .recentlyViewed(lhsRepo), let .recentlyViewed(rhsRepo)):
|
||||
return lhsRepo == rhsRepo
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user