Avatar
Avatar
Yuta Saito
@swift-5.7.3 protocol RethrowsIterator { associatedtype Failure: Error func next() -> Result<Int?, Failure> } struct NonfailableIter: RethrowsIterator { func next() -> Result<Int?, Never> { return .success(1) } } struct FailableIter: RethrowsIterator { func next() -> Result<Int?, Error> { return .success(1) } } func callNextRethrows<T: RethrowsIterator>(_ iter: inout T) -> Result<Int?, T.Failure> { iter.next() } var it = NonfailableIter() let _: Result<Int?, Never> = callNextRethrows(&it) var it2 = FailableIter() _ = try callNextRethrows(&it2).get() (edited)
no output (edited)