A simple code compiled in playground can't be compiled in macOS

fn main() {
    for i in [1,2,3] {
        println!("{}", i);
    }
}

This is the simple code. It can't be compiled on my machine but run well in rust playground.
I'm curious why.
Thanks in advance!

Upgrade your local version of Rust.

1 Like

Specifically, you'll need to update to Rust 1.53, which has improved support for iterating over arrays.

1 Like

I was being stupid...Though I didn't expect an update can change the result of such a simple code. lol

Newer versions of rust don't change the behavior of code that compiles, but new features can turn code that doesn't compile into code that does. The assumption is that you don't go from a newer compiler to an older, and if you want to be able to do that you have to run tests (look for MRSV).

It's perfectly fine to add new functionality over time.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.