Move Equatable conformances to static funcs (#746)

This commit is contained in:
Bas Broek
2017-10-27 16:48:09 +02:00
committed by Ryan Nystrom
parent baf6ccc18b
commit f1768753fd
2 changed files with 18 additions and 14 deletions

View File

@@ -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
}
}

View File

@@ -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
}
}
}