Skip to content

Instantly share code, notes, and snippets.

@jon-cotton
Last active May 12, 2016 07:59
Show Gist options
  • Save jon-cotton/e7829f30513db7097b8e3b0a06292dd0 to your computer and use it in GitHub Desktop.
Save jon-cotton/e7829f30513db7097b8e3b0a06292dd0 to your computer and use it in GitHub Desktop.
Make all string based enums String convertible using the rawValue
extension CustomStringConvertible where Self: RawRepresentible, Self.RawValue == String {
var description: String {
return rawValue
}
}
extension CustomDebugStringConvertible where Self: RawRepresentible, Self.RawValue == String {
var debugDescription: String {
return "\(self)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment