Skip to content

Commit 34d7a55

Browse files
[NFC] Using precondition instead of assert in calls that do not allow negative values
1 parent 5b7993c commit 34d7a55

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Algorithms/Combinations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ extension Collection {
286286
/// accesses the `count` of the base collection.
287287
@inlinable
288288
public func combinations(ofCount k: Int) -> Combinations<Self> {
289-
assert(k >= 0, "Can't have combinations with a negative number of elements.")
289+
precondition(k >= 0, "Can't have combinations with a negative number of elements.")
290290
return Combinations(self, k: k)
291291
}
292292
}

Sources/Algorithms/Permutations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ extension Collection {
242242
///
243243
/// - Complexity: O(1)
244244
public func permutations(ofCount k: Int? = nil) -> Permutations<Self> {
245-
assert(
245+
precondition(
246246
k ?? 0 >= 0,
247247
"Can't have permutations with a negative number of elements.")
248248
return Permutations(self, k: k)

0 commit comments

Comments
 (0)