简体   繁体   中英

How does versioning in the Rust Prelude work?

My question is regarding the std::prelude .

std::prelude in Rust 2021 includes super::v1::* ( v1 of the Rust prelude) and core::prelude::rust_2021::* .

At this point, all versions of Rust (2015-2024) include v1 of the prelude.

In order to use common core modules for future versions of Rust that are different than v1 , and without affecting the current (and previous) version(s) of Rust using v1 , is the plan to do a simple versioning system like v1 , v2 , ..., v[x] , or is there another path forward?

Before Rust's 1.0 release, there was just the std::prelude ; there was no versioning at all. Since development was rapid and the language was highly volatile, it wouldn't make sense to think about keeping prior versions working. The Rust 0.12.0 prelude looks much different than what we know today.

Once planning started for a 1.0 release, some thought had to be put towards backwards compatibility and how portions of the language would grow over time. It was already known that the prelude was likely to change in the future so it was trimmed down and thrown into a versioned module. And that's how the Rust 1.0.0 prelude got to be named std::prelude::v1 .

The prelude was unchanged for the Rust 2018 edition so it stayed as std::prelude::v1 .

When the Rust 2021 edition was in the process of finalizing development, some additions were to be made to the prelude: ultimately adding FromIterator , TryFrom , and TryInto . Was this going to be std::prelude::v2 ? Nay. A whole new versioning scheme for Rust had been developed (the edition system) since v1 was created, it was time to retroactively update the prelude to reflect the edition being used. So in the midst of 2021:

As we venture forth into the future, the Rust 1.62.0 prelude has already added a rust_2024 experimental module. It will probably not be stabilized until much closer to the Rust 2024 edition release, but it already indicates that the path forward is clear.

So no, there will not be a std::prelude::v2 anytime soon; the prelude will follow editions.


See also:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM