Files
swift-estimated-pressures-core/Sources/StaticPressureFeature/FocusableField.swift

22 lines
470 B
Swift

import Foundation
public protocol FocusableField {
var next: Self? { get }
}
extension FocusableField where Self: CaseIterable, Self: Equatable {
public var next: Self? {
guard let index = Self.allCases.firstIndex(of: self)
else { return nil }
let endIndex = Self.allCases.endIndex
let nextIndex = Self.allCases.index(after: index)
guard nextIndex < endIndex else { return nil }
return Self.allCases[nextIndex]
}
}