Skip to content

Commit 3c4be4f

Browse files
committed
Use guard for immediate return instead of if
1 parent 536788b commit 3c4be4f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Algorithms/Permutations.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ where Self: BidirectionalCollection, Element: Comparable
164164
/// - Complexity: O(*n*), where *n* is the length of the collection.
165165
@usableFromInline
166166
internal mutating func nextPermutation() -> Bool {
167-
// ensure we have > 1 element in the collection
168-
if isEmpty { return false }
167+
// Ensure we have > 1 element in the collection.
168+
guard !isEmpty else { return false }
169169
var i = index(before: endIndex)
170170
if i == startIndex { return false }
171171

0 commit comments

Comments
 (0)