Announcing Rust 1.56.0 and Rust 2021
We wrote about plans for the Rust 2021 Edition in May. Editions are a mechanism for opt-in changes that may otherwise pose backwards compatibility risk. See the edition guide for details on how this is achieved. This is 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 detailed release notes for 1.56.0 for lots more information on the release.
Posted Oct 23, 2021 23:05 UTC (Sat)
by tialaramex (subscriber, #21167)
[Link] (2 responses)
For example, in Rust 1.0 if you mean to provide one function for twiddling Things and don't want to require that your callers provide some particular container of Things (such as a Vector) you can instead oblige them to Box up their container on the heap so as to hide its real type from you, writing something like:
fn twiddle(things: Box<IntoIterator<Item= Thing>>)
IntoIterator was relatively new in Rust 1.0 so you might have written Iterator, but Rust's IntoIterator is nicer as a parameter type because it doesn't care whether the parameter you provide is already an iterator or just a container that can be iterated over.
You can't write that twiddle declaration in Rust 2021 today (it's an error because "IntoIterator" isn't a concrete type and you must now write dyn to be explicit if you want dynamic typing) but, you wouldn't want to because you can instead express what you actually cared about, that you just want to make an iterator over things in order to twiddle them and you don't care how it's stored:
fn twiddle(things: impl IntoIterator<Item = Thing>)
However, if you still have code from Rust 1.0 that's in the Rust 2015 edition, you can write this new twiddle function just fine, although of course if you do so your code needs a newer compiler since a Rust 1.0 compiler doesn't know about the impl Trait feature.
Posted Oct 24, 2021 15:06 UTC (Sun)
by bluss (guest, #47454)
[Link] (1 responses)
Posted Oct 24, 2021 19:54 UTC (Sun)
by tialaramex (subscriber, #21167)
[Link]
Announcing Rust 1.56.0 and Rust 2021
Announcing Rust 1.56.0 and Rust 2021
Announcing Rust 1.56.0 and Rust 2021