We all love enums!
Every time when I am adding Result to project, I wonder why it is not included in stdlib.
enum Result<T> {
case success(T)
case failure(Error)
public init(_ value: T) {
self = .success(value)
}
public init(_ error: Error) {
self = .failure(error)
}
}
This is very powerful type while using it with Swift pattern matching operators like switch or if-case .