Skip to content

Commit

Permalink
Adopt typed throws in Fallible<T> methods (#125).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Dec 3, 2024
1 parent c6d16b4 commit 31d7683
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Sources/CoreKit/Models/Fallible+Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extension Fallible {
// MARK: Transformations
//=------------------------------------------------------------------------=

@inlinable public consuming func map<T>(_ map: (Value) throws -> T) rethrows -> Fallible<T> {
@inlinable public consuming func map<T, E>(_ map: (Value) throws(E) -> T) throws(E) -> Fallible<T> {
Fallible<T>(try map(self.value), error: self.error)
}

@inlinable public consuming func map<T>(_ map: (Value) throws -> Fallible<T>) rethrows -> Fallible<T> {
@inlinable public consuming func map<T, E>(_ map: (Value) throws(E) -> Fallible<T>) throws(E) -> Fallible<T> {
try map(self.value).veto(self.error)
}
}
2 changes: 1 addition & 1 deletion Sources/CoreKit/Models/Fallible+Validation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension Fallible {
}

/// Tries to return its `value` but throws `failure()` on `error`.
@inlinable public consuming func prune<Error>(_ failure: @autoclosure () -> Error) throws -> Value where Error: Swift.Error {
@inlinable public consuming func prune<Error>(_ failure: @autoclosure () -> Error) throws(Error) -> Value {
if self.error {
throw failure()
} else {
Expand Down

0 comments on commit 31d7683

Please sign in to comment.