diff --git a/Result/Result.swift b/Result/Result.swift index 3aec80d..720a212 100644 --- a/Result/Result.swift +++ b/Result/Result.swift @@ -132,10 +132,12 @@ extension Result where Error == AnyError { // MARK: - Derive result from failable closure +@available(*, deprecated, renamed: "Result.init(attempt:)") public func materialize(_ f: () throws -> T) -> Result { return Result(attempt: f) } +@available(*, deprecated, renamed: "Result.init(_:)") public func materialize(_ f: @autoclosure () throws -> T) -> Result { return Result(f) } diff --git a/Tests/ResultTests/ResultTests.swift b/Tests/ResultTests/ResultTests.swift index 8e73839..3e6a6e3 100644 --- a/Tests/ResultTests/ResultTests.swift +++ b/Tests/ResultTests/ResultTests.swift @@ -120,18 +120,18 @@ final class ResultTests: XCTestCase { } func testMaterializeProducesSuccesses() { - let result1: Result = materialize(try tryIsSuccess("success")) + let result1: Result = Result(try tryIsSuccess("success")) XCTAssert(result1 == success) - let result2: Result = materialize { try tryIsSuccess("success") } + let result2: Result = Result(attempt: { try tryIsSuccess("success") }) XCTAssert(result2 == success) } func testMaterializeProducesFailures() { - let result1: Result = materialize(try tryIsSuccess(nil)) + let result1: Result = Result(try tryIsSuccess(nil)) XCTAssert(result1.error == error) - let result2: Result = materialize { try tryIsSuccess(nil) } + let result2: Result = Result(attempt: { try tryIsSuccess(nil) }) XCTAssert(result2.error == error) }