This file contains hidden or 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
public struct OptionalCodableEnum<T>: Codable where T: RawRepresentable, T.RawValue: Codable { | |
public let value: T? | |
public init(value: T) { | |
self.value = value | |
} | |
public init(from decoder: Decoder) throws { | |
value = T(rawValue: try decoder.singleValueContainer().decode(T.RawValue.self)) | |
} |