mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-27 11:51:31 +01:00
WIP: segfault
This commit is contained in:
@@ -62,12 +62,12 @@ public enum SaveResult: Hashable {
|
||||
/**
|
||||
`SaveResult.Success` indicates that the `commit()` for the transaction succeeded, either because the save succeeded or because there were no changes to save. The associated value `hasChanges` indicates if there were saved changes or not.
|
||||
*/
|
||||
case Success(hasChanges: Bool)
|
||||
case success(hasChanges: Bool)
|
||||
|
||||
/**
|
||||
`SaveResult.Failure` indicates that the `commit()` for the transaction failed. The associated object for this value is a `CoreStoreError` enum value.
|
||||
*/
|
||||
case Failure(CoreStoreError)
|
||||
case failure(CoreStoreError)
|
||||
|
||||
|
||||
// MARK: Hashable
|
||||
@@ -76,10 +76,10 @@ public enum SaveResult: Hashable {
|
||||
|
||||
switch self {
|
||||
|
||||
case .Success(let hasChanges):
|
||||
case .success(let hasChanges):
|
||||
return self.boolValue.hashValue ^ hasChanges.hashValue
|
||||
|
||||
case .Failure(let error):
|
||||
case .failure(let error):
|
||||
return self.boolValue.hashValue ^ error.hashValue
|
||||
}
|
||||
}
|
||||
@@ -89,26 +89,26 @@ public enum SaveResult: Hashable {
|
||||
|
||||
internal init(hasChanges: Bool) {
|
||||
|
||||
self = .Success(hasChanges: hasChanges)
|
||||
self = .success(hasChanges: hasChanges)
|
||||
}
|
||||
|
||||
internal init(_ error: CoreStoreError) {
|
||||
|
||||
self = .Failure(error)
|
||||
self = .failure(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SaveResult: BooleanType
|
||||
|
||||
extension SaveResult: BooleanType {
|
||||
extension SaveResult: Boolean {
|
||||
|
||||
public var boolValue: Bool {
|
||||
|
||||
switch self {
|
||||
|
||||
case .Success: return true
|
||||
case .Failure: return false
|
||||
case .success: return true
|
||||
case .failure: return false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,10 +121,10 @@ public func == (lhs: SaveResult, rhs: SaveResult) -> Bool {
|
||||
|
||||
switch (lhs, rhs) {
|
||||
|
||||
case (.Success(let hasChanges1), .Success(let hasChanges2)):
|
||||
case (.success(let hasChanges1), .success(let hasChanges2)):
|
||||
return hasChanges1 == hasChanges2
|
||||
|
||||
case (.Failure(let error1), .Failure(let error2)):
|
||||
case (.failure(let error1), .failure(let error2)):
|
||||
return error1 == error2
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user