Skip to content

Commit

Permalink
Add missing Equatable comformances
Browse files Browse the repository at this point in the history
- Collect
- Contains
- Count
- Drop
- Last
  • Loading branch information
broadwaylamb committed Oct 17, 2019
1 parent c4c7f21 commit 4600765
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 61 deletions.
59 changes: 0 additions & 59 deletions RemainingCombineInterface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2100,17 +2100,6 @@ extension Just {
public func append<S>(_ elements: S) -> Publishers.Sequence<[Output], Just<Output>.Failure> where Output == S.Element, S : Sequence
}

extension Publishers.Contains : Equatable where Upstream : Equatable {

/// Returns a Boolean value that indicates whether two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A contains publisher to compare for equality.
/// - rhs: Another contains publisher to compare for equality.
/// - Returns: `true` if the two publishers’ upstream and output properties are equal, `false` otherwise.
public static func == (lhs: Publishers.Contains<Upstream>, rhs: Publishers.Contains<Upstream>) -> Bool
}

extension Publishers.CombineLatest : Equatable where A : Equatable, B : Equatable {

/// Returns a Boolean value that indicates whether two publishers are equivalent.
Expand Down Expand Up @@ -2148,19 +2137,6 @@ extension Publishers.CombineLatest4 : Equatable where A : Equatable, B : Equatab
public static func == (lhs: Publishers.CombineLatest4<A, B, C, D>, rhs: Publishers.CombineLatest4<A, B, C, D>) -> Bool
}

extension Publishers.Collect : Equatable where Upstream : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func == (lhs: Publishers.Collect<Upstream>, rhs: Publishers.Collect<Upstream>) -> Bool
}

extension Publishers.CollectByCount : Equatable where Upstream : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
Expand Down Expand Up @@ -2264,19 +2240,6 @@ extension Publishers.MergeMany : Equatable where Upstream : Equatable {
public static func == (lhs: Publishers.MergeMany<Upstream>, rhs: Publishers.MergeMany<Upstream>) -> Bool
}

extension Publishers.Count : Equatable where Upstream : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
///
/// Equality is the inverse of inequality. For any values `a` and `b`,
/// `a == b` implies that `a != b` is `false`.
///
/// - Parameters:
/// - lhs: A value to compare.
/// - rhs: Another value to compare.
public static func == (lhs: Publishers.Count<Upstream>, rhs: Publishers.Count<Upstream>) -> Bool
}

extension Publishers.Retry : Equatable where Upstream : Equatable {

/// Returns a Boolean value indicating whether two values are equal.
Expand Down Expand Up @@ -2325,17 +2288,6 @@ extension Publishers.Concatenate : Equatable where Prefix : Equatable, Suffix :
public static func == (lhs: Publishers.Concatenate<Prefix, Suffix>, rhs: Publishers.Concatenate<Prefix, Suffix>) -> Bool
}

extension Publishers.Last : Equatable where Upstream : Equatable {

/// Returns a Boolean value that indicates whether two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A last publisher to compare for equality.
/// - rhs: Another last publisher to compare for equality.
/// - Returns: `true` if the two publishers have equal upstream publishers, `false` otherwise.
public static func == (lhs: Publishers.Last<Upstream>, rhs: Publishers.Last<Upstream>) -> Bool
}

extension Publishers.Zip : Equatable where A : Equatable, B : Equatable {

/// Returns a Boolean value that indicates whether two publishers are equivalent.
Expand Down Expand Up @@ -2398,17 +2350,6 @@ extension Publishers.Output : Equatable where Upstream : Equatable {
public static func == (lhs: Publishers.Output<Upstream>, rhs: Publishers.Output<Upstream>) -> Bool
}

extension Publishers.Drop : Equatable where Upstream : Equatable {

/// Returns a Boolean value that indicates whether the two publishers are equivalent.
///
/// - Parameters:
/// - lhs: A drop publisher to compare for equality..
/// - rhs: Another drop publisher to compare for equality..
/// - Returns: `true` if the publishers have equal upstream and count properties, `false` otherwise.
public static func == (lhs: Publishers.Drop<Upstream>, rhs: Publishers.Drop<Upstream>) -> Bool
}

/// A type of object with a publisher that emits before the object has changed.
///
/// By default an `ObservableObject` will synthesize an `objectWillChange`
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Collect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ extension Publishers {
}
}

extension Publishers.Collect: Equatable where Upstream: Equatable {}

extension Publishers.Collect {
private final class Inner<Downstream: Subscriber>
: ReduceProducer<Downstream,
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Contains.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ extension Publishers.Contains {
}
}

extension Publishers.Contains : Equatable where Upstream: Equatable {}

extension Publishers.ContainsWhere {
private final class Inner<Downstream: Subscriber>
: ReduceProducer<Downstream,
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Count.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ extension Publishers {
}
}

extension Publishers.Count: Equatable where Upstream: Equatable {}

extension Publishers.Count {
private final class Inner<Downstream: Subscriber>
: ReduceProducer<Downstream, Upstream.Output, Int, Failure, Void>
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Drop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ extension Publishers {
}
}

extension Publishers.Drop: Equatable where Upstream: Equatable {}

extension Publishers.Drop {
private final class Inner<Downstream: Subscriber>
: Subscription,
Expand Down
2 changes: 2 additions & 0 deletions Sources/OpenCombine/Publishers/Publishers.Last.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ extension Publishers {
}
}

extension Publishers.Last: Equatable where Upstream: Equatable {}

extension Publishers.Last {
private final class Inner<Downstream: Subscriber>
: ReduceProducer<Downstream,
Expand Down
6 changes: 4 additions & 2 deletions Tests/OpenCombineTests/PublisherTests/ScanTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ final class ScanTests: XCTestCase {
}
}

private func shouldNotBeCalled<T, U>(file: StaticString = #file,
line: UInt = #line) -> (T, U) -> T {
private func shouldNotBeCalled<Accumulator, Value>(
file: StaticString = #file,
line: UInt = #line
) -> (Accumulator, Value) -> Accumulator {
return { accumulator, _ in
XCTFail("should not be called", file: file, line: line)
return accumulator
Expand Down
Empty file.

0 comments on commit 4600765

Please sign in to comment.