-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
785f130
commit b0afaf2
Showing
6 changed files
with
104 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[book] | ||
authors = ["The Rust Project Developers"] | ||
authors = ["The Rust Project Developers && Sun Huachuang"] | ||
multilingual = false | ||
src = "src" | ||
title = "The Edition Guide" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,32 @@ | ||
# What are Editions? | ||
|
||
Rust ships releases on a six-week cycle. This means that users get a constant | ||
stream of new features. This is much faster than updates for other languages, | ||
but this also means that each update is smaller. After a while, all of those | ||
tiny changes add up. But, from release to release, it can be hard to look back | ||
and say *"Wow, between Rust 1.10 and Rust 1.20, Rust has changed a lot!"* | ||
|
||
Every two or three years, we'll be producing a new *edition* of Rust. Each | ||
edition brings together the features that have landed into a clear package, with | ||
fully updated documentation and tooling. New editions ship through the usual | ||
release process. | ||
|
||
This serves different purposes for different people: | ||
|
||
- For active Rust users, it brings together incremental changes into an | ||
easy-to-understand package. | ||
|
||
- For non-users, it signals that some major advancements have landed, which | ||
might make Rust worth another look. | ||
|
||
- For those developing Rust itself, it provides a rallying point for the project as a | ||
whole. | ||
|
||
## Compatibility | ||
|
||
When a new edition becomes available in the compiler, crates must explicitly opt | ||
in to it to take full advantage. This opt in enables editions to contain | ||
incompatible changes, like adding a new keyword that might conflict with | ||
identifiers in code, or turning warnings into errors. A Rust compiler will | ||
support all editions that existed prior to the compiler's release, and can link | ||
crates of any supported editions together. | ||
Edition changes only affect the way the compiler initially parses the code. | ||
Therefore, if you're using Rust 2015, and | ||
one of your dependencies uses Rust 2018, it all works just fine. The opposite | ||
situation works as well. | ||
|
||
Just to be clear: most features will be available on all editions. | ||
People using any edition of Rust will continue to see improvements as new | ||
stable releases are made. In some cases however, mainly when new keywords are | ||
added, but sometimes for other reasons, there may be new features that are only | ||
available in later editions. You only need to upgrade if you want to take | ||
advantage of such features. | ||
|
||
## Trying out the 2018 edition | ||
|
||
At the time of writing, there are two editions: 2015 and 2018. 2015 is today's | ||
Rust; Rust 2018 will ship later this year. To transition to the 2018 edition | ||
from the 2015 edition, you'll want to get started with the [transition | ||
section](transitioning-your-code-to-a-new-edition.html). | ||
# 什么是版本(Editions)? | ||
|
||
Rust 六周发布一次新版本。这意味着用户可以获得不断的新功能。 | ||
这比其他语言的更新要快得多,但这也意味着每次更新都会更小。 | ||
一段时间之后,所有这些微小的变化都加进来了。 | ||
但是,从正式发布到正式发布,很难回头看看 *哇,在 Rust 1.10和 Rust 1.20之间,Rust已经发生了很大变化!* | ||
|
||
每隔两三年,我们将制作一个新 *版本* 的 Rust。 | ||
每个版本都将功能集成到一个清晰的包中,并提供全面更新的文档和工具。 | ||
新版本通过正常的发布流程发布。 | ||
|
||
这为不同的人提供不同的目的: | ||
|
||
- 对于活跃的 Rust 用户,它将增量更改集成到易于理解的包中。 | ||
|
||
- 对于非用户而言,它表明一些重大进步已经落地,这可能使 Rust 值得再看一眼。 | ||
|
||
- 对于那些开发 Rust 本身的人来说,它为整个项目提供了一个集结点。 | ||
|
||
## 兼容性 | ||
当编译器中出现新版本时,crates 必须明确选择使用它才能充分利用它。 | ||
此选择允许版本包含不兼容的更改,例如添加可能与代码中的标识符冲突的新关键字,或将警告转换为错误。 | ||
Rust 编译器将支持编译器发布之前存在的所有版本,并且可以将任何受支持版本的 crates 链接在一起。 | ||
版本更改仅影响编译器最初解析代码的方式。 | ||
因此,如果您正在使用 Rust 2015,并且您的某个依赖项使用 Rust 2018,那么一切正常。相反的情况也适用。 | ||
|
||
需要明确的是:大多数功能都适用于所有版本。随着新的稳定版本的发布,使用任何版本的 Rust 的人将继续看到改进。 | ||
但是,在某些情况下,主要是在添加新关键字时,但有时由于其他原因,可能会有新功能仅在以后的版本中提供。如果要利用此类功能,则只需升级。 | ||
|
||
## 试一下2018版本 | ||
在撰写本文时,有两个版本:2015和2018。2015是现在的 Rust版本; Rust 2018将于今年晚些时候发布。 | ||
要从2015版本过渡到2018版本,您需要开始使用[迁移说明](transitioning-your-code-to-a-new-edition.html)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
# Introduction | ||
# 简介 | ||
|
||
Welcome to the Rust Edition Guide! "Editions" are Rust's way of communicating | ||
large changes in the way that it feels to write Rust code. | ||
欢迎来到 Rust 版本(Edition)使用指南! "Editions" 是通过编写 Rust 代码来传达巨大改变的一种方式。 | ||
|
||
In this guide, we'll discuss: | ||
在指南中,我们将讨论: | ||
* 什么是版本(editions) | ||
* 每个版本什么样 | ||
* 如何将你的代码从一个版本迁移到另一个版本 | ||
|
||
* What editions are | ||
* What each edition is about | ||
* How to migrate your code from one edition to another | ||
|
||
Note that the standard library grows with each Rust release; there are *many* | ||
additions to the standard library that are not called out in this guide. Only | ||
the major ones are, but there's tons of medium and small things that are | ||
great too. You may want to check out [the standard library | ||
documentation](https://doc.rust-lang.org/std/) as well. | ||
请注意,标准库随每个Rust版本的增长而增长; 标准库中有*许多*添加的内容,本指南未对其进行说明。 | ||
只包含那些主要的变化,当然同时也有大量的中小型的改变也很棒。 | ||
您可能还想查看[标准库文档](https://doc.rust-lang.org/std/)。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
# Rust 2015 | ||
|
||
Rust 2015 has a theme of "stability". It commenced with the release of 1.0, | ||
and is the "default edition". The edition system was conceived in late 2017, | ||
but Rust 1.0 was released in May of 2015. As such, 2015 is the edition | ||
that you get when you don't specify any particular edition, for backwards | ||
compatibility reasons. | ||
Rust 2015 的主题是“稳定性”。 它从1.0版本开始,是“默认版”。 | ||
该版本系统于2017年底构思,但 Rust 1.0 于2015年5月发布。因此,2015年是您未指定任何特定版本时获得的版本,出于向后兼容性原因。 | ||
|
||
"Stability" is the theme of Rust 2015 because 1.0 marked a huge change in | ||
Rust development. Previous to Rust 1.0, Rust was changing on a daily basis. | ||
This made it very difficult to write large software in Rust, and made it | ||
difficult to learn. With the release of Rust 1.0 and Rust 2015, we committed | ||
to backwards compatibility, ensuring a solid foundation for people to build | ||
projects on top of. | ||
“稳定性”是 Rust 2015 的主题,因为1.0标志着 Rust 开发的巨大变化。 在 Rust 1.0 之前,Rust 每天都在变化。 这使得在 Rust 中编写大型软件变得非常困难,并且难以学习。 | ||
随着 Rust 1.0 和 Rust 2015 的发布,我们致力于向后兼容,确保为人们构建项目奠定坚实的基础。 | ||
|
||
Since it's the default edition, there's no way to port your code to Rust | ||
2015; it just *is*. You'll be transitioning *away* from 2015, but never | ||
really *to* 2015. As such, there's not much else to say about it! | ||
由于它是默认版本,因此无法将代码移植到 Rust 2015; 它 *就是*。 你将从 2015 开始 *过渡*,但从未真正 *到* 2015版。因此,没有什么可说的了! |