[NCGenerics] add coverage for any Error

This commit is contained in:
Kavon Farvardin
2023-12-22 10:57:36 -08:00
parent 8b870e9e6c
commit b6b27eb3b5

View File

@@ -31,6 +31,22 @@ public extension Eq where Self: Equatable {
}
}
/// MARK: Result
public enum Either<Success, Failure: Error> {
case success(Success)
case failure(Failure)
}
extension Either where Failure == Swift.Error {
public init(catching body: () throws -> Success) {
do {
self = .success(try body())
} catch {
self = .failure(error)
}
}
}
/// MARK: Iteration
public protocol Generator: ~Copyable {