Comment

Comment by Pxtl

I've never used Rust - in a conventional language you'd just have a mutable variable defined outside of the loop and used and incremented inside of the loop. I assume Rust's for-loops can't access the outside variable scope that way?

Like (pseudocode)

    var i = 0
    for(item in items) {
      item.DoThing(i)
      i+=1
    }
Does rust not allow that kind of mutation and access of a variable from outside the loop within the loop?
parent Pxtl 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton