mirror of
https://github.com/apple/swift-algorithms
synced 2026-11-24 04:17:48 +00:00
Merge pull request #61 from LucianoPAlmeida/normalizing-assert
[NFC] Using precondition instead of assert in calls that do not allow negative values
This commit is contained in:
2 files changed
+2
-2
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user