mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[NCGenerics] add coverage for any Error
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user