Last active
December 3, 2017 20:37
-
-
Save brow/ecbea64ec94a4c765e76dedbe2110073 to your computer and use it in GitHub Desktop.
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
// These three types are simplified versions of the ones in my real project. | |
public struct Domain { | |
public let string: String | |
} | |
public enum Taglike { | |
case someCase | |
} | |
final class Contact { | |
let email = "" | |
} | |
private enum Cell { | |
case contact(Contact) | |
case contactsSeparator | |
case tag(Taglike) | |
case showCreatedByMe | |
case showWorkAppDomain(Domain) | |
case showWorkAppDomainAndTrashed | |
case addContact | |
case addTag((String) -> ()) | |
case enableContacts | |
} | |
private func ==(lhs: Cell, rhs: Cell) -> Bool { | |
switch (lhs, rhs) { | |
case let (.contact(a), .contact(b)): | |
return a.email == b.email | |
case let (.tag(a), .tag(b)): | |
return a == b | |
case (.showCreatedByMe, .showCreatedByMe), | |
(.showWorkAppDomain, .showWorkAppDomain), | |
(.showWorkAppDomainAndTrashed, .showWorkAppDomainAndTrashed), | |
(.addContact, .addContact), | |
(.addTag, .addTag), | |
(.enableContacts, .enableContacts), | |
(.contactsSeparator, .contactsSeparator): | |
return true | |
case (.contact, _), | |
(.tag, _), | |
(.showCreatedByMe, _), | |
(.showWorkAppDomain, _), | |
(.showWorkAppDomainAndTrashed, _), | |
(.addContact, _), | |
(.addTag, _), | |
(.enableContacts, _), | |
(.contactsSeparator, _): | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment