(start..).take(len) already exists for the old range types, it just returns std::iter::Take<RangeFrom<T>> instead of Range<T>. I think adding it for the new range types is a good idea since they don't directly implement Iterator
1 Like
The two loops in this function...
pub fn main() {
for i in 0..=26 {
println!("{i}")
}
for i in 0..27 {
println!("{i}")
}
}
... do not compile to the same assembly code (playground) so clearly there is still at least some work to be done. (I find LLVM's choice of fully unrolling the second loop questionable on code size grounds, but just the fact that it did that only for the second loop indicates that its understanding of the first loop is probably weaker.)
1 Like
Once those are using the new range types it'll be way easier to do something about it, since we'll be able to have the latter attempt to be the former.
2 Likes