| ▲ | tialaramex 3 hours ago | |
More specifically for x in y consumes y in Rust. https://doc.rust-lang.org/std/keyword.for.html explains how a loop is de-sugared https://rust.godbolt.org/z/5jzhxYM51 ... shows that today ranges like 0..5 aren't Copy even if that would be possible, which means if they're consumed they're gone, whereas an array of integers is Copy and so consuming it doesn't mean it's gone, you can just consume it again. The desire is that Rust 2027 edition will change the nice syntax for ranges to produce new ranges like core::ranges::Range which are Copy if possible and only IntoIterator, the original ranges are never Copy but are Iterator, we now regret this choice. | ||