Mara Profile picture
Sep 22, 2022 15 tweets 6 min read Read on X
🆕🦀 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 use std::future::{ready, In...
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 let f = future::poll_fn(|cx...
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 fn calc(x: NonZeroI32) -> N...
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 extern "C" {     ...
The OsString type now implements std::fmt::Write, which means you can write to it using the write!() and writeln!() macros.

6/15 use std::{fmt::Write, fs, p...
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 use std::{mem, net::{Ipv4Ad...
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 static PTR: AtomicPtr<Data>...
The std::slice::from_raw_parts function is now a const fn, allowing for even more code crimes at compile time. 😌

9/15 static X: [u32; 4] = [1, 2,...
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 impl<T> Drop for MyArc<T> {...
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 $ rustup component add rust...
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 Two text files.  The first ...
Cargo now also supports multiple --target flags, to build for more than one target at once.

13/15 $ cargo build --target=aarc...
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

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Mara

Mara Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @m_ou_se

Dec 15, 2022
🆕🦀 Just an hour ago, #rustlang 1.66.0 was released!

As usual, here's a thread with some of the highlights. 🧵

1/12
Rust 1.66 comes with std::hint::black_box(), a function that does nothing. However, the compiler tries its very best to pretend it doesn't know what it does.

It is useful in benchmarks, to prevent the compiler from optimizing your entire benchmark away.

2/12 use std::hint::black_box; use std::sync::atomic::{AtomicU64,
The Option type got a new method: Option::unzip(). It's basically the opposite of Option::zip(): it splits an Option of a pair into a pair of Options.

3/12 impl<T, U> Option<(T, U)>  pub fn unzip(self) -> (Option<T>,
Read 12 tweets
Nov 3, 2022
🆕🦀 About an hour ago, @rustlang 1.65.0 was released.

As is tradition, here's a thread with some of the highlights. 🧵

1/10
Today's Rust release contains a long-awaited feature: generic associated types (GATs). 🎉

This allows associated types to be generic, which unlocks a lot of useful patterns.

See the blog post about the stabilization of this feature for details: blog.rust-lang.org/2022/10/28/gat…

2/10 trait LendingIterator {     type Item<'a> where Self: 'a;
Another big new feature in today's Rust release is let-else statements.

You can now write things like:

let Ok(a) = i32::from_str("123") else { return };

without needing an if or match statement. This can be useful to avoid deeply nested if statements.

3/10 fn parse_key_value(s: &str) -> Result<(&str, i32), ParseErro
Read 10 tweets
Aug 11, 2022
🆕🦀 Just moments ago, @rustlang 1.63.0 was released! 🎉

It's quite a big release, with even more exciting new features than usual!

Here's a thread with some of the highlights. 🧵

1/16

blog.rust-lang.org/2022/08/11/Rus…
One of the features I'm most excited about is scoped threads! (Although I'm obviously biased, since I worked on this myself.)

As of today, you can use std::thread::scope() to spawn threads that borrow local variables, reducing the need for Arc! ✨

doc.rust-lang.org/stable/std/thr…

2/16 let mut a = vec![1, 2, 3]; let mut x = 0;  std::thread::scop
Another thing I'm very excited about, is that Mutex, RwLock and Condvar now all have a _const_ new function.

This means you can now have a static Mutex without having to use lazy_static or once_cell. ✨

3/16 use std::sync::Mutex;  static S: Mutex<String> = Mutex::new(
Read 16 tweets
Jun 30, 2022
🆕🦀 Just moments ago, @rustlang 1.62.0 was released! 🎉

As usual, a thread with some of the highlights. 🧵

1/9

blog.rust-lang.org/2022/06/30/Rus…
Cargo now has 'cargo add' built-in: a (sub)command to add a crate to your Cargo.toml. It automatically looks up the latest version, and shows you the available features of the crate.

See `cargo add --help` for more details.

2/9 $ cargo add rand     Updating crates.io index       Adding r
On Linux and several BSDs, std::sync's Mutex, RwLock, and Condvar now no longer do any allocations. They used to be (heap-allocated) wrappers around pthread lock types, but have been replaced by a minimal, more efficient, futex-based implementations.

3/9

Read 9 tweets
May 16, 2022
🦀 As of Rust 1.62 (going into beta this week), std::sync::Mutex, RwLock, and Condvar no longer do any allocations on Linux. 🎉

Benchmarking locks is extremely tricky, as their performance depends heavily on the exact use case, but there are very noticable differences: A table showing before and after times of three tests.  test
std's Mutex basically used to contain a Pin<Box<pthread_mutex_t>>, where the pinned Box was only necessary because pthread_mutex_t is not guaranteed movable. The new Mutex no longer uses pthread, and instead directly uses the futex syscall, making it smaller and more efficient.
Also, the new RwLock on Linux prefers writers, which prevents writer starvation. pthread_rwlock_t prefers readers by default, to allow recursive read locking. Rust's RwLock does not make recursion guarantees, and on several platforms (including Windows) already preferred writers.
Read 4 tweets
Jan 13, 2022
🦀✨ @rustlang 1.58.0 was released just now!

blog.rust-lang.org/2022/01/13/Rus…

As usual, a thread to highlight some of the new features:

1/11
First, a feature we've all been waiting for: Format argument capturing!

let name = "world";
println!("Hello {name}!");

For now, this only works with identifiers, not with more complicated expressions. E.g. `println!("{a.f() + 10}")` does not work.

2/11

Newly stabilized in the standard library is File::options(). It's identical to OpenOptions::new(), but you don't have to import the OpenOptions type separately from the File type.

3/11 These two lines do the same thing, but the first one doesn't
Read 11 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(