3 ms·
What is the difference between Rust XXXX edition and Rust X.X version? I suspect it's simply a limitation of features to let the compiler version improve but h
by Narann 6y ago
What is the difference between Rust XXXX edition and Rust X.X version?
I suspect it's simply a limitation of features to let the compiler version improve but have an explicit list of supported/unsupported feature every 4 years to avoid the fragmentation.
But I can't find information about this on the article.
- majewsky 6y agoEditions are like different dialects of the same language. A particular compiler version can understand multiple editions, and crates can choose which edition of the language they're using. The closest equivalent to editions in other languages are specification revisions. For example, with the C language, you have the C99 standard from 1999, the C11 standard from 2011, and so on. Each compiler will have a default setting for which standard to follow, but you can usually change it via command-line flag for each invocation (e.g. `-std=c99` in GCC). So you can have a file written in C99 next to a file written in C11. Introducing a new edition enables some changes to the language that are otherwise not possible with Rust's strict backwards-compatibility rules. For example, Rust 2018 introduced the "async" and "await" keywords. In Rust 2015, you could have a variable called "async". That's not possible in Rust 2018 anymore, so that's a breaking change. But each crate specifies what edition it's using in its Cargo.toml, so you can mix an older crate written in Rust 2015 that uses that variable name somewhere in its code, with a newer crate written in Rust 2018 (or, soon, Rust 2021). So the Rust team doesn't have to do a single release where they say "all code using async as a variable name is broken now", they can continue supporting old code while also enabling new code at the same time.