Skip to content

Commit f8c8d1e

Browse files
authored
Merge pull request #101 from nkristek/array_contentequatable
Add conditional ContentEquatable conformance to Array
2 parents 14c6668 + 632a80a commit f8c8d1e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/ContentEquatable.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ extension Optional: ContentEquatable where Wrapped: ContentEquatable {
5050
}
5151
}
5252
}
53+
54+
extension Array: ContentEquatable where Element: ContentEquatable {
55+
/// Indicate whether the content of `self` is equals to the content of
56+
/// the given source value.
57+
///
58+
/// - Parameters:
59+
/// - source: A source value to be compared.
60+
///
61+
/// - Returns: A Boolean value indicating whether the content of `self` is equals
62+
/// to the content of the given source value.
63+
@inlinable
64+
public func isContentEqual(to source: [Element]) -> Bool {
65+
return count == source.count
66+
&& zip(self, source).allSatisfy { $0.isContentEqual(to: $1) }
67+
}
68+
}

0 commit comments

Comments
 (0)