MijickCamera/Sources/Internal/Extensions/CaseIterable++.swift

23 lines
659 B
Swift
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// CaseIterable++.swift of MijickCamera
//
// Created by Tomasz Kurylik. Sending from Kraków!
// - Mail: tomasz.kurylik@mijick.com
// - GitHub: https://github.com/FulcrumOne
// - Medium: https://medium.com/@mijick
//
// Copyright ©2024 Mijick. All rights reserved.
import Foundation
// MARK: Next
extension CaseIterable where Self: Equatable {
func next() -> Self {
guard let index = Self.allCases.firstIndex(of: self) else { return self }
let nextIndex = Self.allCases.index(after: index)
return Self.allCases[nextIndex == Self.allCases.endIndex ? Self.allCases.startIndex : nextIndex]
}
}