From b3cdf4541afe38150488e9c77cbf439ce57c565f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oscar=20Bystr=C3=B6m=20Ericsson?= Date: Sun, 8 Dec 2024 09:23:24 +0100 Subject: [PATCH] Adopt typed throws in Guarantee types (#125). --- Sources/CoreKit/Guarantee+Validation.swift | 2 +- Sources/CoreKit/Models/Fallible+Validation.swift | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/CoreKit/Guarantee+Validation.swift b/Sources/CoreKit/Guarantee+Validation.swift index cb9f37c8..a8c3e62b 100644 --- a/Sources/CoreKit/Guarantee+Validation.swift +++ b/Sources/CoreKit/Guarantee+Validation.swift @@ -48,7 +48,7 @@ extension Guarantee { /// /// - Requires: The given `value` must satisfy the `predicate` of this type. /// - @inlinable public init(_ value: consuming Value, prune error: @autoclosure () -> Error) throws where Error: Swift.Error { + @inlinable public init(_ value: consuming Value, prune error: @autoclosure () -> Error) throws(Error) { guard Self.predicate(value) else { throw error() } self.init(unsafe:/**/value) } diff --git a/Sources/CoreKit/Models/Fallible+Validation.swift b/Sources/CoreKit/Models/Fallible+Validation.swift index cc29bf51..64d34be0 100644 --- a/Sources/CoreKit/Models/Fallible+Validation.swift +++ b/Sources/CoreKit/Models/Fallible+Validation.swift @@ -31,19 +31,19 @@ extension Fallible { } } - /// Tries to return its `value` but throws `failure()` on `error`. - @inlinable public consuming func prune(_ failure: @autoclosure () -> Error) throws(Error) -> Value { + /// Tries to return its `value` but throws `error()` on `error`. + @inlinable public consuming func prune(_ error: @autoclosure () -> Error) throws(Error) -> Value { if self.error { - throw failure() + throw error() } else { return self.value } } - /// Tries to return its `value` but returns `failure()` on `error`. - @inlinable public consuming func result(_ failure: @autoclosure () -> Error) -> Result { + /// Tries to return its `value` but returns `error()` on `error`. + @inlinable public consuming func result(_ error: @autoclosure () -> Error) -> Result { if self.error { - return Result.failure(failure()) + return Result.failure(error()) } else { return Result.success(self.value) }