Mara Profile picture
Rust dev, Electronics engineer, Author, @rustlang Library team lead, ADHD, Polyamorous, Lesbian, She/Her

Sep 22, 2022, 15 tweets

🆕🦀 A few hours ago, @rustlang 1.64.0 was released! 🎉

Just like every six weeks, at every new release, here's a thread with some of the highlights. 🧵

1/15

blog.rust-lang.org/2022/09/22/Rus…

Rust now has a new async-related trait: IntoFuture.

The .await syntax be used on anything that implements IntoFuture. (Similar to how, with a for loop, you can iterate over anything that implements IntoIterator.)

This allows types to provide easier async interfaces.

2/15

Today's Rust release also comes with two more async-related tools:

The std::future::poll_fn function allows you to easily create a future from a closure (like iter::from_fn for iterators).

The std::task::ready!() macro extracts a Poll::Ready, or returns early on Pending.

3/15

The Rust's NonZero types got new methods for (unsigned) addition, multiplication, exponentiation, absolute numbers, and next-power-of-two calculation, that all preserve "non-zero-ness": they return a NonZero type, because we know the result is never zero.

4/15

The types for interfacing with C, such as std::os::raw::c_int and c_void, have been moved to core::ffi. They are still available in the old (and new) location in `std`, but are now also available in `core`, for #![no_std] programs.

5/15

The OsString type now implements std::fmt::Write, which means you can write to it using the write!() and writeln!() macros.

6/15

The IP and socket address types, Ipv4Addr, Ipv6Addr, SocketAddrV4 and SocketAddrV6 now use a minimal, trivial internal representation, instead the libc types.

This clears the way for moving these types to `core` (no_std), and using these in const fns, in the future.

7/15

The atomic compare_exchange functions no longer require the success memory ordering to be at least as strong as the failure ordering.

(The same restriction was dropped from C++ as part of C++17.)

For example, compare_exchange(a, b, Release, Acquire) is now accepted.

8/15

The std::slice::from_raw_parts function is now a const fn, allowing for even more code crimes at compile time. 😌

9/15

To allow for sound (unsafe) implementations of reference-counted allocated objects, it's no longer undefined behavior to keep a reference to something that's de-allocated, as long as you don't use it, and the object's bytes all reside in an UnsafeCell (e.g. an atomic).

10/15

Rust 1.64 is the last release that ships with the deprecated old language server, RLS. Instead, starting with this release, the rustup distribution now includes @rust_analyzer.

(Nothing changes for most users. E.g. the VS Code extension will keep handling updates itself.)

11/15

Cargo now makes it possible for a Cargo.toml file in a workspace to inherit dependencies and various package properties from the root Cargo.toml file. This makes it easier to handle large workspaces.

12/15

Cargo now also supports multiple --target flags, to build for more than one target at once.

13/15

Initial support for the Nintendo Switch has been added: aarch64-nintendo-switch-freestanding as a "tier 3" target.

This doesn't include the Rust standard library, but makes it easier to compile no_std Rust programs for this platform.

14/15

github.com/rust-lang/rust…

And that's everything for today's thread!

For a more complete list of changes in Rust 1.64, check the release notes:

Rust: github.com/rust-lang/rust…
Cargo: github.com/rust-lang/carg…
Clippy: github.com/rust-lang/rust…

Enjoy! ✨🦀

15/15

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling