From 04c735bad07845055cc12c4816e771f3176c8656 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 20 Oct 2021 17:27:28 -0700 Subject: [PATCH] Apply Mark's suggestions from code review Co-authored-by: Mark Rousskov --- posts/2021-10-21-Rust-1.56.0.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/posts/2021-10-21-Rust-1.56.0.md b/posts/2021-10-21-Rust-1.56.0.md index be23fa805..2621a14c2 100644 --- a/posts/2021-10-21-Rust-1.56.0.md +++ b/posts/2021-10-21-Rust-1.56.0.md @@ -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: @@ -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 @@ -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`