[NFC] Using precondition instead of assert in calls that do not allow negative values

This commit is contained in:
Luciano Almeida committed 2021-01-15 20:15:52 -03:00
1 parent 5b7993ca8d
commit 34d7a55d1a
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -286,7 +286,7 @@ extension Collection {
/// accesses the `count` of the base collection.
@inlinable
public func combinations(ofCount k: Int) -> Combinations<Self> {
assert(k >= 0, "Can't have combinations with a negative number of elements.")
precondition(k >= 0, "Can't have combinations with a negative number of elements.")
return Combinations(self, k: k)
}
}
+1 -1
View File
@@ -242,7 +242,7 @@ extension Collection {
///
/// - Complexity: O(1)
public func permutations(ofCount k: Int? = nil) -> Permutations<Self> {
assert(
precondition(
k ?? 0 >= 0,
"Can't have permutations with a negative number of elements.")
return Permutations(self, k: k)