Skip to content

Instantly share code, notes, and snippets.

@maximkrouk
Created June 11, 2020 21:24
Show Gist options
  • Save maximkrouk/9b91dfc21ef61bf42f52b2813320b984 to your computer and use it in GitHub Desktop.
Save maximkrouk/9b91dfc21ef61bf42f52b2813320b984 to your computer and use it in GitHub Desktop.
import Foundation
public struct CodingKeys: CodingKey {
public var stringValue: String
public init(stringValue: String) {
self.stringValue = stringValue
}
@available(*, deprecated, message: "Always fails.")
public init?(intValue: Int) { nil }
public var intValue: Int? { .none }
public static func custom(_ value: String) -> Self { .init(stringValue: value) }
}
extension CodingKeys: ExpressibleByStringLiteral {
public init(stringLiteral value: String) {
self = .custom(value)
}
}
@maximkrouk
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment