feat: added cleanscript
This commit is contained in:
57
appendix/appendix-05-editions.html
Normal file
57
appendix/appendix-05-editions.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>E - Editions</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2 id="appendix-e-editions"><a class="header" href="#appendix-e-editions">Appendix E: Editions</a></h2>
|
||||
<p>In Chapter 1, you saw that <code>cargo new</code> adds a bit of metadata to your
|
||||
<em>Cargo.toml</em> file about an edition. This appendix talks about what that means!</p>
|
||||
<p>The Rust language and compiler have a six-week release cycle, meaning users get
|
||||
a constant stream of new features. Other programming languages release larger
|
||||
changes less often; Rust releases smaller updates more frequently. After a
|
||||
while, all of these tiny changes add up. But from release to release, it can be
|
||||
difficult to look back and say, “Wow, between Rust 1.10 and Rust 1.31, Rust has
|
||||
changed a lot!”</p>
|
||||
<p>Every three years or so, the Rust team produces a new Rust <em>edition</em>. Each
|
||||
edition brings together the features that have landed into a clear package with
|
||||
fully updated documentation and tooling. New editions ship as part of the usual
|
||||
six-week release process.</p>
|
||||
<p>Editions serve different purposes for different people:</p>
|
||||
<ul>
|
||||
<li>For active Rust users, a new edition brings together incremental changes into
|
||||
an easy-to-understand package.</li>
|
||||
<li>For non-users, a new edition signals that some major advancements have
|
||||
landed, which might make Rust worth another look.</li>
|
||||
<li>For those developing Rust, a new edition provides a rallying point for the
|
||||
project as a whole.</li>
|
||||
</ul>
|
||||
<p>At the time of this writing, four Rust editions are available: Rust 2015, Rust
|
||||
2018, Rust 2021, and Rust 2024. This book is written using Rust 2024 edition
|
||||
idioms.</p>
|
||||
<p>The <code>edition</code> key in <em>Cargo.toml</em> indicates which edition the compiler should
|
||||
use for your code. If the key doesn’t exist, Rust uses <code>2015</code> as the edition
|
||||
value for backward compatibility reasons.</p>
|
||||
<p>Each project can opt in to an edition other than the default 2015 edition.
|
||||
Editions can contain incompatible changes, such as including a new keyword that
|
||||
conflicts with identifiers in code. However, unless you opt in to those
|
||||
changes, your code will continue to compile even as you upgrade the Rust
|
||||
compiler version you use.</p>
|
||||
<p>All Rust compiler versions support any edition that existed prior to that
|
||||
compiler’s release, and they can link crates of any supported editions
|
||||
together. Edition changes only affect the way the compiler initially parses
|
||||
code. Therefore, if you’re using Rust 2015 and one of your dependencies uses
|
||||
Rust 2018, your project will compile and be able to use that dependency. The
|
||||
opposite situation, where your project uses Rust 2018 and a dependency uses
|
||||
Rust 2015, works as well.</p>
|
||||
<p>To be clear: Most features will be available on all editions. Developers using
|
||||
any Rust edition will continue to see improvements as new stable releases are
|
||||
made. However, in some cases, mainly when new keywords are added, some new
|
||||
features might only be available in later editions. You will need to switch
|
||||
editions if you want to take advantage of such features.</p>
|
||||
<p>For more details, see <a href="https://doc.rust-lang.org/stable/edition-guide"><em>The Rust Edition Guide</em></a>. This is a
|
||||
complete book that enumerates the differences between editions and explains how
|
||||
to automatically upgrade your code to a new edition via <code>cargo fix</code>.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user