Created
November 12, 2018 12:57
-
-
Save hamsternik/266cdff69a4fa441771e7581421fa7f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public protocol EnumerableEnum: RawRepresentable where RawValue == Int { | |
static var firstIndex: Int { get } | |
} | |
public extension EnumerableEnum { | |
static var firstIndex: Int { return 0 } | |
static var all: [Self] { | |
var index = firstIndex | |
return Array(AnyIterator { | |
defer { index += 1 } | |
return Self(rawValue: index) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment