Skip to content

Instantly share code, notes, and snippets.

@onevcat
Last active March 12, 2018 04:53
Show Gist options
  • Save onevcat/f8321f3ebd7f8c189f09192f6f85db79 to your computer and use it in GitHub Desktop.
Save onevcat/f8321f3ebd7f8c189f09192f6f85db79 to your computer and use it in GitHub Desktop.
enumset.stencil
{% for enum in types.implementing.EnumSet|enum %}
extension {{ enum.name }} {
{% if not enum.hasAssociatedValues %}
static let all: [{{ enum.name }}] = [
{% for case in enum.cases %} .{{ case.name }}{% if not forloop.last %},{% endif %}
{% endfor %}]
{% endif %}
static let count: Int = {{ enum.cases.count }}
}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment