Skip to content

Instantly share code, notes, and snippets.

View rickpasveer's full-sized avatar

Rick Pasveer rickpasveer

  • Booqable
  • Netherlands
View GitHub Profile
@rickpasveer
rickpasveer / enumerateEnum.swift
Last active July 7, 2016 09:12 — forked from kristopherjohnson/enumerateEnum.swift
Helper functions for enumerating values of a Swift enum
protocol ConvertibleFromRawInt {
static func fromRaw(raw: Int) -> Self?
}
// Note: Tried to use Swift's standard RawRepresentable protocol rather
// than ConvertibleFromRawInt, but couldn't get it to compile.
// Don't know whether it is a Swift bug or something I was doing wrong.
// Generator for a sequence of contiguous ConvertibleFromRawInt values
class ConvertibleFromRawIntGenerator<T: ConvertibleFromRawInt>: GeneratorType {