The Rust team is happy to announce a new version of Rust, 1.53.0. Rust is a programming language that is empowering everyone to build reliable and efficient software.
If you have a previous version of Rust installed via rustup, getting Rust 1.53.0 is as easy as:
$ rustup update stable
If you don't have it already, you can get rustup
from the appropriate page on our website, and check out the
detailed release notes for 1.53.0 on GitHub.
What's in 1.53.0 stable
This release contains several new language features and many new library features,
including the long-awaited IntoIterator
implementation for arrays.
See the detailed release notes
to learn about other changes not covered by this post.
IntoIterator for arrays
This is the first Rust release in which arrays implement the IntoIterator
trait.
This means you can now iterate over arrays by value:
for i in [1, 2, 3] {
..
}
Previously, this was only possible by reference, using &[1, 2, 3]
or [1, 2, 3].iter()
.
Similarly, you can now pass arrays to methods expecting a T: IntoIterator
:
let set = BTreeSet::from_iter([1, 2, 3]);
for (a, b) in some_iterator.chain([1]).zip([1, 2, 3]) {
..
}
This was not implemented before, due to backwards compatibility problems.
Because IntoIterator
was already implemented for references to arrays,
array.into_iter()
already compiled in earlier versions,
resolving to (&array).into_iter()
.
As of this release, arrays implement IntoIterator
with a small workaround to avoid breaking code.
The compiler will continue to resolve array.into_iter()
to (&array).into_iter()
,
as if the trait implementation does not exist.
This only applies to the .into_iter()
method call syntax, and does not
affect any other syntax such as for e in [1, 2, 3]
, iter.zip([1, 2, 3])
or
IntoIterator::into_iter([1, 2, 3])
, which all compile fine.
Since this special case for .into_iter()
is only required to avoid breaking existing code,
it is removed in the new edition, Rust 2021, which will be released later this year.
See the edition announcement
for more information.
Or patterns
Pattern syntax has been extended to support |
nested anywhere in the pattern.
This enables you to write Some(1 | 2)
instead of Some(1) | Some(2)
.
match result {
Ok(Some(1 | 2)) => { .. }
Err(MyError { kind: FileNotFound | PermissionDenied, .. }) => { .. }
_ => { .. }
}
Unicode identifiers
Identifiers can now contain non-ascii characters. All valid identifier characters in Unicode as defined in UAX #31 can now be used. That includes characters from many different scripts and languages, but does not include emoji.
For example:
const BLÅHAJ: &str = "🦈";
struct 人 {
名字: String,
}
let α = 1;
The compiler will warn about potentially confusing situations involving different scripts. For example, using identifiers that look very similar will result in a warning.
warning: identifier pair considered confusable between `s` and `s`
HEAD branch name support in Cargo
Cargo no longer assumes the default HEAD
of git repositories is named master
.
This means you no longer need to specify branch = "main"
for git dependencies
from a repository where the default branch is called main
.
Incremental Compilation remains off by default
As previously discussed on the blog post for version 1.52.1, incremental compilation has been turned off by default on the stable Rust release channel. The feature remains available on the beta and nightly release channels. For the 1.53.0 stable release, the method for reenabling incremental is unchanged from 1.52.1.
Stabilized APIs
The following methods and trait implementations were stabilized.
array::from_ref
array::from_mut
AtomicBool::fetch_update
AtomicPtr::fetch_update
BTreeSet::retain
BTreeMap::retain
BufReader::seek_relative
cmp::min_by
cmp::min_by_key
cmp::max_by
cmp::max_by_key
DebugStruct::finish_non_exhaustive
Duration::ZERO
Duration::MAX
Duration::is_zero
Duration::saturating_add
Duration::saturating_sub
Duration::saturating_mul
f32::is_subnormal
f64::is_subnormal
IntoIterator for array
{integer}::BITS
io::Error::Unsupported
NonZero*::leading_zeros
NonZero*::trailing_zeros
Option::insert
Ordering::is_eq
Ordering::is_ne
Ordering::is_lt
Ordering::is_gt
Ordering::is_le
Ordering::is_ge
OsStr::make_ascii_lowercase
OsStr::make_ascii_uppercase
OsStr::to_ascii_lowercase
OsStr::to_ascii_uppercase
OsStr::is_ascii
OsStr::eq_ignore_ascii_case
Peekable::peek_mut
Rc::increment_strong_count
Rc::decrement_strong_count
slice::IterMut::as_slice
AsRef<[T]> for slice::IterMut
impl SliceIndex for (Bound<usize>, Bound<usize>)
Vec::extend_from_within
Other changes
There are other changes in the Rust 1.53.0 release: check out what changed in Rust, Cargo, and Clippy.
Contributors to 1.53.0
Many people came together to create Rust 1.53.0. We couldn't have done it without all of you. Thanks!