If one side is Never, then the value will never be that side, so .value could always return the other.
If both sides are Never, then .value would then naturally return Never, which fits in perfectly.
it could be implemented like this:
public extension Either where Left == Never {
var value: Right {
switch self {
case .left: preconditionFailure("`Never` should not be reachable")
case .right(let right): return right
}
}
}
public extension Either where Right == Never {
var value: Left {
switch self {
case .right: preconditionFailure("`Never` should not be reachable")
case .left(let left): return left
}
}
}
If one side is
Never, then the value will never be that side, so.valuecould always return the other.If both sides are
Never, then.valuewould then naturally returnNever, which fits in perfectly.it could be implemented like this: