It probably doesn't need to be unsafe
, really.
It could be something like
trait InfiniteIterator : Iterator {
fn next_infinite(&mut self) -> Self::Item {
self.next().expect("should have a value because it's an infinite iterator")
}
}
Though that would need the desugaring to know it's infinite, and emit a loop
instead of the usual while let
.