Skip to content

Commit cda6fdd

Browse files
authored
Merge pull request #61 from LucianoPAlmeida/normalizing-assert
[NFC] Using precondition instead of assert in calls that do not allow negative values
2 parents d872b64 + 34d7a55 commit cda6fdd

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Sources/Algorithms/Combinations.swift

+1-1
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

+1-1
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)