mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 13:50:32 +05:30
9 lines
263 B
Swift
9 lines
263 B
Swift
extension CaseIterable where Self: Equatable {
|
|
func next() -> Self {
|
|
let all = Self.allCases
|
|
let idx = all.firstIndex(of: self)!
|
|
let next = all.index(after: idx)
|
|
return all[next == all.endIndex ? all.startIndex : next]
|
|
}
|
|
}
|