Created
September 11, 2018 15:22
-
-
Save homerooliveira/062e43ccc0a5fb6809e326bc2eb16866 to your computer and use it in GitHub Desktop.
CaseIterable template for Sourcery.
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
// swiftlint:disable all | |
#if swift(>=4.2) | |
#else | |
protocol CaseIterable { } | |
{% for enum in types.based.CaseIterable|enum %} | |
{{ enum.accessLevel }} extension {{ enum.name }} { | |
{% if not enum.hasAssociatedValues %} | |
static let allCases: [{{ enum.name }}] = [ | |
{% for case in enum.cases %} .{{ case.name }}{% if not forloop.last %},{% endif %} | |
{% endfor %}] | |
{% endif %} | |
} | |
{% endfor %} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment