Official Updates of Rust

  • Source: Rust Daily
  • The author:RustDaily newspaper group
  • Post editor: Zhang Handong

Build the common vision of Async Rust

·Niko Matsakis represents Async Foundations Working Group

The Asynchronous Infrastructure Working Group believes Rust can become one of the hottest options for building distributed systems, from embedded devices to basic cloud services. No matter what they use it for, we hope all developers enjoy using Async Rust. To do this, we need to move Async Rust out of its current “MVP” state and make it available to everyone.

We are collaborating to build a shared vision document for Async Rust. Our goal is to engage the entire community in the collective imagination: How can we make the end-to-end experience of using asynchronous I/O not only a pragmatic choice, but also a happy one?

Click here to read a Chinese translation of the article

Rust 1.51 stable release

$ rustup update stable

This release mainly brings:

  1. Const Generics MVP: blog.rust-lang.org/2021/02/26/…
  2. BTW STD :: Array ::IntoIter is also stable
pub struct IntoIter<T, const N: usize> {
    data: [MaybeUninit<T>; N],
    alive: Range<usize>,}impl<T, const N: usize> IntoIter<T, N> {

}
Copy the code
  1. New Cargo Crate dependency management mechanism. For details, see RFC 2957. In short, by setting resolver=”2″ to tell Cargo to enable the new resolution features method, the current problem with Cargo merging features by default is solved. Summary:
  • For dev Dependencies: When packages are shared as regular dependencies and development dependencies, development dependency Features is enabled only if the current build contains development dependencies
  • Host Dependencies: When packages are shared as regular and build Dependencies or proc-macro, the features for regular Dependencies are independent of build Dependencies or proc-Macro.
  • Target Dependencies: When packages appear multiple times in the build diagram and one instance is a target-specific dependency, features for target-specific Dependencies are enabled only if the Target is currently being built.

However, this can lead to longer compile times (since the same Crate can be compiled more than once). See Cargo Guide’s “Feature Resolver” section for more details.

[package]
resolver = "2"
# Or if you're using a workspace
[workspace]
resolver = "2"
Copy the code
  1. Debug mode build times have been optimized for MacOS platforms. Instead of using the dsymutil tool to collect debug information to the. DSYM directory, the new method reduces the build time of the debuginfo and significantly reduces the disk space used. But expect more build reports from macOS users.
[profile.dev]
split-debuginfo = "unpacked"
Copy the code

This setting enables the new behavior

  1. Stabilized a lot of apis, but I won’t go into details. It is worth mentioning thattask::WakeIt’s stable now.

Blog.rust-lang.org/2021/03/25/…

Rust 2021 Edition is scheduled for release on October 21

Rust iterates with a small release every six weeks and an Edition release every three years. The 2021 Edition will be a smaller version than the 2018 Edition, with an official release scheduled for October 21, 2021 (1.56). It’s not entirely clear what features will be included in the 2021 Edition, but some are already in the works. These include:

Prelude adds new traits: TryFrom/TryInto, FromIterator

More ergonomic closure variable capture rules.

Closure variable capture is now very strict, even if you reference only the fields of a single struct, it will capture the entire struct. The new rules will capture variables as small as possible. For example, the following two examples will not compile in 2018 Edition, but will work in 2021 Edition:

let _a = &mutfoo.a; | | &mut foo.b; // (Edition 2018) Error! cannot borrow `foo`

let _a = &mut foo.a;
move || foo.b; // (Edition 2018) Error! cannot move `foo`Improved OR pattern matching// Previously needed to write like this or rule match:
Some(Enum::A) | Some(Enum::B) | Some(Enum::C) | Some(Enum::D) => ..

// 2021 Edition can be written like this!
Some(Enum::A | Enum::B | Enum::C | Enum::D) => ..
Copy the code

Unify the default visibility of macros defined by Macro_rules and remove #[macro_export] and #[macro_use] macros: All types of visibility in Rust are private by default and can only be changed to public visibility by adding pub or pub(PATH). Macro_rules define this differently, and you need to use ‘#[macro_export]’ to make the macro public. Starting with 2021 Edition, macro_rules defines macros that are private by default, again requiring pub or pub(PATH) to change visibility. The #[macro_export] and #[macro_use] macros are useless.

link

The Rust compiler back end was upgraded to LLVM 12

link

Gloo: An official RustwASM project seeks Maintainer

Gloo is an official project (801 star) under RustwASM, is looking for a maintainer because the author can no longer maintain it. Interested partners can try to contact.

Original issue address

Miri runs on WASM!

There is now a way to compile MIRI into WASM.

issue

Contents: Rust Chinese Collection (Rust_Magazine) march issue