3 ms·
Doesn't `let x = xs[i]` immutably borrow from xs? So for the duration of x's lifetime (which is the entire for-body block), xs cannot be changed and therefore i
by mindleyhilner 9y ago
Doesn't `let x = xs[i]` immutably borrow from xs? So for the duration of x's lifetime (which is the entire for-body block), xs cannot be changed and therefore its length must remain the same.
Though this might be information that rustc knows about but not LLVM.
- pcwalton 9y agoIn the case of "let x = &xs[i]" it would immutably borrow. But we'd need more MIR optimizations to make use of that fact.