Skip to content

Commit

Permalink
Adopt typed throws in Guarantee types (#125).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Dec 8, 2024
1 parent 2eae447 commit b3cdf45
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Sources/CoreKit/Guarantee+Validation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension Guarantee {
///
/// - Requires: The given `value` must satisfy the `predicate` of this type.
///
@inlinable public init<Error>(_ value: consuming Value, prune error: @autoclosure () -> Error) throws where Error: Swift.Error {
@inlinable public init<Error>(_ value: consuming Value, prune error: @autoclosure () -> Error) throws(Error) {
guard Self.predicate(value) else { throw error() }
self.init(unsafe:/**/value)
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/CoreKit/Models/Fallible+Validation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ extension Fallible {
}
}

/// Tries to return its `value` but throws `failure()` on `error`.
@inlinable public consuming func prune<Error>(_ failure: @autoclosure () -> Error) throws(Error) -> Value {
/// Tries to return its `value` but throws `error()` on `error`.
@inlinable public consuming func prune<Error>(_ 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<Error>(_ failure: @autoclosure () -> Error) -> Result<Value, Error> {
/// Tries to return its `value` but returns `error()` on `error`.
@inlinable public consuming func result<Error>(_ error: @autoclosure () -> Error) -> Result<Value, Error> {
if self.error {
return Result.failure(failure())
return Result.failure(error())
} else {
return Result.success(self.value)
}
Expand Down

0 comments on commit b3cdf45

Please sign in to comment.