diff --git a/Sources/Algorithms/Combinations.swift b/Sources/Algorithms/Combinations.swift index 643fead..07c1991 100644 --- a/Sources/Algorithms/Combinations.swift +++ b/Sources/Algorithms/Combinations.swift @@ -286,7 +286,7 @@ extension Collection { /// accesses the `count` of the base collection. @inlinable public func combinations(ofCount k: Int) -> Combinations { - 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) } } diff --git a/Sources/Algorithms/Permutations.swift b/Sources/Algorithms/Permutations.swift index 6a548f9..937f63c 100644 --- a/Sources/Algorithms/Permutations.swift +++ b/Sources/Algorithms/Permutations.swift @@ -242,7 +242,7 @@ extension Collection { /// /// - Complexity: O(1) public func permutations(ofCount k: Int? = nil) -> Permutations { - assert( + precondition( k ?? 0 >= 0, "Can't have permutations with a negative number of elements.") return Permutations(self, k: k)