Skip to content

Commit

Permalink
Merge pull request CoreOffice#9 from bwetherfield/fix-just-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbean committed Jul 14, 2019
2 parents 70d82fe + d81bce7 commit a1f3af0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
Expand Up @@ -252,7 +252,11 @@ struct XMLCoderElement: Equatable {
extension XMLCoderElement {
init(key: String, box: UnkeyedBox) {
self.init(key: key, elements: box.map {
XMLCoderElement(key: "", box: $0)
if $0 is KeyedBox {
return XMLCoderElement(key: "", box: $0)
} else {
return XMLCoderElement(key: key, box: $0)
}
})
}

Expand Down
5 changes: 2 additions & 3 deletions Tests/XMLCoderTests/EnumAssociatedValueTestSimple.swift
Expand Up @@ -14,7 +14,6 @@ private enum IntOrString {
}

extension IntOrString: Codable {

enum CodingKeys: String, CodingKey {
case int
case string
Expand All @@ -23,9 +22,9 @@ extension IntOrString: Codable {
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .int(let value):
case let .int(value):
try container.encode(value, forKey: .int)
case .string(let value):
case let .string(value):
try container.encode(value, forKey: .string)
}
}
Expand Down

0 comments on commit a1f3af0

Please sign in to comment.