Skip to content

Instantly share code, notes, and snippets.

@Dev1an
Last active May 5, 2022 11:24
Show Gist options
  • Save Dev1an/3383459c7360097f73a9e8f9025903ce to your computer and use it in GitHub Desktop.
Save Dev1an/3383459c7360097f73a9e8f9025903ce to your computer and use it in GitHub Desktop.
enum TypeGenerator {
private static var last: Chainable.Type = Chain<Void>.self
private enum Chain<X>: Chainable {
static func chain() -> Chainable.Type { Chain<Self>.self }
}
static func next() -> Chainable.Type {
Self.last = Self.last.chain()
return Self.last
}
}
protocol Chainable {
static func chain() -> Chainable.Type
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment