Skip to content

Commit

Permalink
Apply Mark's suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Rousskov <[email protected]>
  • Loading branch information
cuviper and Mark-Simulacrum authored Oct 21, 2021
1 parent 772a85d commit 04c735b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions posts/2021-10-21-Rust-1.56.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: The Rust Release Team
release: true
---

The Rust team is happy to announce a new version of Rust, 1.56.0, and "Rust 2021" as well.
The Rust team is happy to announce a new version of Rust, 1.56.0. This stabilizes the 2021 edition as well.
Rust is a programming language empowering everyone to build reliable and efficient software.

If you have a previous version of Rust installed via rustup, getting Rust 1.56.0 is as easy as:
Expand All @@ -26,29 +26,30 @@ from the appropriate page on our website, and check out the
### Rust 2021

We wrote about plans for Rust 2021 [in May](https://blog.rust-lang.org/2021/05/11/edition-2021.html).
This is a smaller step for an edition, especially compared to 2018, but there
This a smaller edition, especially compared to 2018, but there
are still some nice quality-of-life changes that require an edition opt-in to
avoid breaking some corner cases in existing code. See the new chapters of the
edition guide below for more details on each new feature and guidance for
migration.

* [Additions to the prelude](https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html): `TryInto`, `TryFrom`, and `FromIterator`.
* [Default Cargo feature resolver](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) is now version 2.
* [`IntoIterator` for arrays](https://doc.rust-lang.org/edition-guide/rust-2021/IntoIterator-for-arrays.html) now includes `array.into_iter()` calls.
* [Disjoint capture in closures](https://doc.rust-lang.org/edition-guide/rust-2021/disjoint-capture-in-closures.html) rather than always capturing whole identifiers.
* [`IntoIterator` for arrays](https://doc.rust-lang.org/edition-guide/rust-2021/IntoIterator-for-arrays.html) now includes `array.into_iter()` calls.
* [Or patterns in macro-rules](https://doc.rust-lang.org/edition-guide/rust-2021/or-patterns-macro-rules.html) now match top-level `A|B` in `:pat`.
* [Default Cargo feature resolver](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) is now version 2.
* [Additions to the prelude](https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html): `TryInto`, `TryFrom`, and `FromIterator`.
* [Panic macro consistency](https://doc.rust-lang.org/edition-guide/rust-2021/panic-macro-consistency.html) now always uses `format_args!(..)`, just like `println!()`.
* [Reserving syntax](https://doc.rust-lang.org/edition-guide/rust-2021/reserving-syntax.html) for `ident#`, `ident"..."`, and `ident'...'`.
* [Warnings promoted to errors](https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html): `bare_trait_objects` and `ellipsis_inclusive_range_patterns`.
* [Or patterns in macro-rules](https://doc.rust-lang.org/edition-guide/rust-2021/or-patterns-macro-rules.html) now match top-level `A|B` in `:pat`.

#### Disjoint capture in closures

Closures automatically capture values or references to identifiers that are
used in the body, but before 2021, they were always captured in whole. The new
disjoint-capture feature will likely simply the way you write closures, so
used in the body, but before 2021, they were always captured as a whole. The new
disjoint-capture feature will likely simplify the way you write closures, so
let's look at a quick example:

```rust
// 2015 or 2018 edition code
let a = SomeStruct::new();

drop(a.x); // Move out of one field of the struct
Expand All @@ -67,19 +68,19 @@ above example will compile fine!
This new behavior is only activated in the new edition, since it can change
the order in which fields are dropped. As for all edition changes, an
automatic migration is available, which will update your closures for which
this matters. It can insert `let _ = &a;` inside the closure to force the
this matters by inserting `let _ = &a;` inside the closure to force the
entire struct to be captured as before.

#### Migrating to 2021

The guide includes migration instructions for all new features, and in general
[transitioning an existing project to a new edition](https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html),
[transitioning an existing project to a new edition](https://doc.rust-lang.org/edition-guide/editions/transitioning-an-existing-project-to-a-new-edition.html).
In many cases `cargo fix` can automate the necessary changes. You may even
find that no changes in your code are needed at all for 2021!

However small this edition appears on the surface, it's still the product
of a lot of hard work from many contributors. Please join us in
[celebration and thanks](https://github.com/rust-lang/rust/issues/88623)!
of a lot of hard work from many contributors: see our dedicated
[celebration and thanks](https://github.com/rust-lang/rust/issues/88623) tracker!

### Cargo `rust-version`

Expand Down

0 comments on commit 04c735b

Please sign in to comment.