Skip to content

Instantly share code, notes, and snippets.

@brow
Last active December 3, 2017 20:37
Show Gist options
  • Save brow/ecbea64ec94a4c765e76dedbe2110073 to your computer and use it in GitHub Desktop.
Save brow/ecbea64ec94a4c765e76dedbe2110073 to your computer and use it in GitHub Desktop.
// 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