rethrows
doesn’t make sense forget()
, because it doesn’t take a closure argument. Did you meanthrows
, or are you proposing a new meaning forrethrows
?
@ksluder the language feature for this is already implemented as part of this pitch. This discussion is just for Error
protocol to confirm to this existing feature. I have added detail in my original post as well.
I think there’s an even easier solution to your problem without introducing a new language feature: offer a non-throwing version of get when Failure is Never:
extension Result where Failure == Never {
func get() -> Success {
switch self {
case .success(let x): return x
case .failure(_): fatalError("unreachable")
}
}
}
This is exactly what I want to be addressed, instead of adding separate implementation for Never
type for every generic type, using existing language feature this can be handled with the same implementation.