-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e59d11d
commit c6396db
Showing
15 changed files
with
52 additions
and
52 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
@_exported import Node | ||
|
||
public enum ExtractionError: Error { | ||
case unexpectedNil | ||
case invalidType | ||
} | ||
|
||
extension Node { | ||
public func extract(_ key: PathIndex) throws -> Node { | ||
guard let node = self[key] else { | ||
throw ExtractionError.unexpectedNil | ||
} | ||
|
||
return node | ||
} | ||
|
||
public func extract<N: NodeInitializable>(_ key: PathIndex) throws -> N { | ||
guard let node = self[key] else { | ||
throw ExtractionError.unexpectedNil | ||
} | ||
|
||
return try N(with: node) | ||
} | ||
|
||
|
||
public func extract<N: NodeInitializable>(_ key: PathIndex) throws -> [N] { | ||
guard let node = self[key]?.nodeArray else { | ||
throw ExtractionError.unexpectedNil | ||
} | ||
|
||
return try [N](with: node) | ||
} | ||
} | ||
//public enum ExtractionError: Error { | ||
// case unexpectedNil | ||
// case invalidType | ||
//} | ||
// | ||
//extension Node { | ||
// public func extract(_ key: PathIndex) throws -> Node { | ||
// guard let node = self[key] else { | ||
// throw ExtractionError.unexpectedNil | ||
// } | ||
// | ||
// return node | ||
// } | ||
// | ||
// public func extract<N: NodeInitializable>(_ key: PathIndex) throws -> N { | ||
// guard let node = self[key] else { | ||
// throw ExtractionError.unexpectedNil | ||
// } | ||
// | ||
// return try N(: node) | ||
// } | ||
// | ||
// | ||
// public func extract<N: NodeInitializable>(_ key: PathIndex) throws -> [N] { | ||
// guard let node = self[key]?.nodeArray else { | ||
// throw ExtractionError.unexpectedNil | ||
// } | ||
// | ||
// return try [N](with: node) | ||
// } | ||
//} |
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
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
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