-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix decoding of arrays with optional elements (#48)
Also move protocols for tricks with metatypes to new Metatypes file. Fix formatting of long lines in related files. * Fix decoding of arrays with optional elements * Rename header comment in Metatypes file * Fix formatting
- Loading branch information
1 parent
a4954c9
commit d4e7673
Showing
9 changed files
with
213 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Metatypes.swift | ||
// XMLCoder | ||
// | ||
// Created by Max Desiatov on 30/12/2018. | ||
// | ||
|
||
/// Type-erased protocol helper for a metatype check in generic `decode` | ||
/// overload. | ||
protocol AnyEmptySequence { | ||
init() | ||
} | ||
|
||
protocol AnyArray { | ||
static var elementType: Any.Type { get } | ||
} | ||
|
||
extension Array: AnyEmptySequence, AnyArray { | ||
static var elementType: Any.Type { | ||
return Element.self | ||
} | ||
} | ||
|
||
extension Dictionary: AnyEmptySequence {} | ||
|
||
/// Type-erased protocol helper for a metatype check in generic `decode` | ||
/// overload. | ||
protocol AnyOptional { | ||
init() | ||
} | ||
|
||
extension Optional: AnyOptional { | ||
init() { | ||
self = nil | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.