mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
9 lines
267 B
Swift
9 lines
267 B
Swift
extension CaseIterable where Self: Equatable {
|
|
func next() -> Self {
|
|
let all = Self.allCases
|
|
let index = all.firstIndex(of: self)!
|
|
let next = all.index(after: index)
|
|
return all[next == all.endIndex ? all.startIndex : next]
|
|
}
|
|
}
|