minor Swift 3 cleanup

This commit is contained in:
John Estropia
2016-12-08 18:59:41 +09:00
parent 5d2956d674
commit a27556f294
21 changed files with 453 additions and 255 deletions

View File

@@ -216,6 +216,17 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera
}
// MARK: Equatable
public static func == (lhs: MigrationChain, rhs: MigrationChain) -> Bool {
return lhs.versionTree == rhs.versionTree
&& lhs.rootVersions == rhs.rootVersions
&& lhs.leafVersions == rhs.leafVersions
&& lhs.valid == rhs.valid
}
// MARK: Internal
internal let rootVersions: Set<String>
@@ -249,14 +260,3 @@ public struct MigrationChain: ExpressibleByNilLiteral, ExpressibleByStringLitera
fileprivate let versionTree: [String: String]
}
// MARK: - MigrationChain: Equatable
public func == (lhs: MigrationChain, rhs: MigrationChain) -> Bool {
return lhs.versionTree == rhs.versionTree
&& lhs.rootVersions == rhs.rootVersions
&& lhs.leafVersions == rhs.leafVersions
&& lhs.valid == rhs.valid
}

View File

@@ -83,6 +83,24 @@ public enum MigrationResult: Hashable {
}
// MARK: Equatable
public static func == (lhs: MigrationResult, rhs: MigrationResult) -> Bool {
switch (lhs, rhs) {
case (.success(let migrationTypes1), .success(let migrationTypes2)):
return migrationTypes1 == migrationTypes2
case (.failure(let error1), .failure(let error2)):
return error1 == error2
default:
return false
}
}
// MARK: Hashable
public var hashValue: Int {
@@ -116,21 +134,3 @@ public enum MigrationResult: Hashable {
self = .failure(CoreStoreError(error))
}
}
// MARK: - SetupResult: Equatable
public func == (lhs: MigrationResult, rhs: MigrationResult) -> Bool {
switch (lhs, rhs) {
case (.success(let migrationTypes1), .success(let migrationTypes2)):
return migrationTypes1 == migrationTypes2
case (.failure(let error1), .failure(let error2)):
return error1 == error2
default:
return false
}
}

View File

@@ -122,6 +122,27 @@ public enum MigrationType: Hashable {
}
// MARK: Equatable
public static func == (lhs: MigrationType, rhs: MigrationType) -> Bool {
switch (lhs, rhs) {
case (.none(let version1), .none(let version2)):
return version1 == version2
case (.lightweight(let source1, let destination1), .lightweight(let source2, let destination2)):
return source1 == source2 && destination1 == destination2
case (.heavyweight(let source1, let destination1), .heavyweight(let source2, let destination2)):
return source1 == source2 && destination1 == destination2
default:
return false
}
}
// MARK: Hashable
public var hashValue: Int {
@@ -140,24 +161,3 @@ public enum MigrationType: Hashable {
}
}
}
// MARK: - MigrationType: Equatable
public func == (lhs: MigrationType, rhs: MigrationType) -> Bool {
switch (lhs, rhs) {
case (.none(let version1), .none(let version2)):
return version1 == version2
case (.lightweight(let source1, let destination1), .lightweight(let source2, let destination2)):
return source1 == source2 && destination1 == destination2
case (.heavyweight(let source1, let destination1), .heavyweight(let source2, let destination2)):
return source1 == source2 && destination1 == destination2
default:
return false
}
}

View File

@@ -86,6 +86,24 @@ public enum SetupResult<T: StorageInterface>: Hashable {
}
// MARK: Equatable
public static func == <T: StorageInterface, U: StorageInterface>(lhs: SetupResult<T>, rhs: SetupResult<U>) -> Bool {
switch (lhs, rhs) {
case (.success(let storage1), .success(let storage2)):
return storage1 === storage2
case (.failure(let error1), .failure(let error2)):
return error1 == error2
default:
return false
}
}
// MARK: Hashable
public var hashValue: Int {
@@ -118,21 +136,3 @@ public enum SetupResult<T: StorageInterface>: Hashable {
self = .failure(CoreStoreError(error))
}
}
// MARK: - SetupResult: Equatable
public func == <T: StorageInterface, U: StorageInterface>(lhs: SetupResult<T>, rhs: SetupResult<U>) -> Bool {
switch (lhs, rhs) {
case (.success(let storage1), .success(let storage2)):
return storage1 === storage2
case (.failure(let error1), .failure(let error2)):
return error1 == error2
default:
return false
}
}