-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from ikesyo/casting
Make `castOrFail` function public to support class cluster for now
- Loading branch information
Showing
4 changed files
with
30 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Casting.swift | ||
// Himotoki | ||
// | ||
// Created by Syo Ikeda on 6/21/16. | ||
// Copyright © 2016 Syo Ikeda. All rights reserved. | ||
// | ||
|
||
internal func castOrFail<T>(e: Extractor) throws -> T { | ||
return try castOrFail(e.rawValue) | ||
} | ||
|
||
public func castOrFail<T>(any: Any?) throws -> T { | ||
guard let result = any as? T else { | ||
throw typeMismatch("\(T.self)", actual: any, keyPath: nil) | ||
} | ||
|
||
return result | ||
} |
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