皇上,还记得我吗?我就是1999年那个Linux伊甸园啊-----24小时滚动更新开源资讯,全年无休!

Rust 1.53.0 发布

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 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.

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!

转自 https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html