Skip to content

Commit

Permalink
Merge pull request #251 from antitypical/deprecate-try-functions
Browse files Browse the repository at this point in the history
[3.x] Deprecate `try` functions
  • Loading branch information
ikesyo authored Sep 26, 2017
2 parents c844618 + 71cc40a commit 1abb664
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ matrix:
- swift test
env:
- JOB=Linux
- SWIFT_VERSION=3.1-DEVELOPMENT-SNAPSHOT-2017-03-01-a
- SWIFT_VERSION=3.1
sudo: required
dist: trusty
language: generic
Expand Down
2 changes: 2 additions & 0 deletions Result/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public func materialize<T>(_ f: @autoclosure () throws -> T) -> Result<T, NSErro
/// This is convenient for wrapping Cocoa API which returns an object or `nil` + an error, by reference. e.g.:
///
/// Result.try { NSData(contentsOfURL: URL, options: .dataReadingMapped, error: $0) }
@available(*, deprecated, message: "This will be removed in Result 4.0. Use `Result.init(attempt:)` instead. See https://github.com/antitypical/Result/issues/85 for the details.")
public func `try`<T>(_ function: String = #function, file: String = #file, line: Int = #line, `try`: (NSErrorPointer) -> T?) -> Result<T, NSError> {
var error: NSError?
return `try`(&error).map(Result.success) ?? .failure(error ?? Result<T, NSError>.error(function: function, file: file, line: line))
Expand All @@ -165,6 +166,7 @@ public func `try`<T>(_ function: String = #function, file: String = #file, line:
/// This is convenient for wrapping Cocoa API which returns a `Bool` + an error, by reference. e.g.:
///
/// Result.try { NSFileManager.defaultManager().removeItemAtURL(URL, error: $0) }
@available(*, deprecated, message: "This will be removed in Result 4.0. Use `Result.init(attempt:)` instead. See https://github.com/antitypical/Result/issues/85 for the details.")
public func `try`(_ function: String = #function, file: String = #file, line: Int = #line, `try`: (NSErrorPointer) -> Bool) -> Result<(), NSError> {
var error: NSError?
return `try`(&error) ?
Expand Down

0 comments on commit 1abb664

Please sign in to comment.