Skip to content

Commit

Permalink
Merge pull request #108 from Carthage/equatable-tweaks
Browse files Browse the repository at this point in the history
Equatable tweaks
  • Loading branch information
mdiep authored Jul 22, 2018
2 parents eae2415 + c1a3d0a commit 6771f8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
17 changes: 1 addition & 16 deletions Sources/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

/// An error originating from ReactiveTask.
public enum TaskError: Error {
public enum TaskError: Error, Equatable {
/// A shell task exited unsuccessfully.
case shellTaskFailed(Task, exitCode: Int32, standardError: String?)

Expand All @@ -33,18 +33,3 @@ extension TaskError: CustomStringConvertible {
}
}
}

extension TaskError: Equatable {
public static func == (lhs: TaskError, rhs: TaskError) -> Bool {
switch (lhs, rhs) {
case let (.shellTaskFailed(lhsTask, lhsCode, lhsErr), .shellTaskFailed(rhsTask, rhsCode, rhsErr)):
return lhsTask == rhsTask && lhsCode == rhsCode && lhsErr == rhsErr

case let (.posixError(lhsCode), .posixError(rhsCode)):
return lhsCode == rhsCode

default:
return false
}
}
}
15 changes: 1 addition & 14 deletions Sources/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,6 @@ extension Task: Hashable {
}
}

private func ==<Key, Value: Equatable>(lhs: [Key: Value]?, rhs: [Key: Value]?) -> Bool {
switch (lhs, rhs) {
case let (lhs?, rhs?):
return lhs == rhs

case (.none, .none):
return true

default:
return false
}
}

/// A private class used to encapsulate a Unix pipe.
private final class Pipe {
typealias ReadProducer = SignalProducer<Data, TaskError>
Expand Down Expand Up @@ -331,7 +318,7 @@ public enum TaskEvent<T>: TaskEventType {
}
}

extension TaskEvent where T: Equatable {
extension TaskEvent: Equatable where T: Equatable {
public static func == (lhs: TaskEvent<T>, rhs: TaskEvent<T>) -> Bool {
switch (lhs, rhs) {
case let (.launch(left), .launch(right)):
Expand Down

0 comments on commit 6771f8c

Please sign in to comment.