Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making Enum conform to Equatable and CaseIterable #124

Closed
wants to merge 1 commit into from
Closed

Making Enum conform to Equatable and CaseIterable #124

wants to merge 1 commit into from

Conversation

mackoj
Copy link
Contributor

@mackoj mackoj commented Feb 27, 2019

Remove old cases implementation and replacing it with CaseIterable

@yonaskolb
Copy link
Owner

Thanks @mackoj. Could you run the tests so that the fixtures get updated, and commit them. That's why the tests are failing.
Could you also add a changelog entry

@mackoj
Copy link
Contributor Author

mackoj commented Mar 1, 2019

Ok, I will do it today.

@mackoj
Copy link
Contributor Author

mackoj commented Mar 1, 2019

It actually breaks Swift 4.1 support because CaseIterable has been added in Swift 4.2

@@ -1,14 +1,8 @@
{% if description %}
/** {{ description }} */
{% endif %}
public enum {{ enumName }}: {{ type }}, Codable {
public enum {{ enumName }}: {{ type }}, Codable, Equatable, CaseIterable {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can conditionally use the template for swift 4.2 Vs 4.1

#if swift(>=4.2)
// swift 4.2 goes here
#else 
// swift 4.1 goes here 
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea I will do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done it but I still have to fix the fixture...

Remove old `cases` implementation and replacing it with `CaseIterable`
@yonaskolb
Copy link
Owner

yonaskolb commented Mar 14, 2019

Perhaps a cleaner way would be to just define a custom CaseIterable below Swift 4.2, perhaps in Coding.swift

#if swift(<4.2)
public protocol CaseIterable {
    static let allCases: [Self] { get }
}
#endif

@yonaskolb
Copy link
Owner

In the interest of time I've just opened another PR here #133. I opted to simply drop Swift 4.1 support

@yonaskolb yonaskolb closed this Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants