Mara Bos Profile picture
Rust dev, Electronics engineer, Founder/CTO of Fusion Engineering, @rustlang Library team lead, ADHD, Polyamorous, Lesbian, She/Her

Aug 11, 2022, 16 tweets

🆕🦀 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. 🧵


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! ✨…


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


Another major addition are types and traits for the native file descriptors/handles/sockets of various platforms.

E.g. OwnedFd represents a Unix file descriptor that should be closed, while BorrowedFd borrows a file descriptor using a lifetime.



A smaller but very useful new feature is std::array::from_fn.

Use it to create an array based on a closure, which is called for every index of the array.

Not only the element type, but also the number of elements can be automatically inferred from context.


VecDeque<u8> now implements both io::Read and io::Write, such that it can be used by generic I/O functions like io::copy and write!().

Write appends to the end (just like Write for Vec<u8>), while Read reads and removes from the start, like a circular buffer.


Just like Vec and String and some other collections already had, BinaryHeap, OsString, and PathBuf now also have a `try_reserve` method for fallible allocation.

Rather than panicking when out of memory, this method returns an Result::Err that you can handle manually.


The ToOwned trait now has a new (provided) method: clone_into().

In some cases, it allows for more efficient operation than the to_owned() method, because it can re-use an already existing allocation of the object you're cloning into.


The old borrow checker is now completely phased out, leaving only the "non-lexical lifetimes" (NLL) borrow checker. This shouldn't change anything for you, other than some differences (hopefully improvements) in how lifetime errors are reported.



If a function uses both `<T: Trait>` and `impl Trait` syntax for generics in its signature, callers are now allowed to explicitly specify the generic arguments of the first form, even if the function also uses `impl Trait` syntax.


Today's release also includes a small bug fix in the language. It's technically a breaking change, but unlikely to affect any real world code.

Writing [expr; 0] (to create an array of zero elements) would not drop `expr`, but instead forget (leak) it. That has been fixed.


Another (very minor) breaking change to the language also involves Drop. Enums that implement Drop can no longer be casted (with the `as` operator) to an integer.

(Casting enums to integers was already restricted to enums that don't have any fields, aka C-style enums.)


The documentation now includes some clarification on what `unsafe` means in edge cases like using File to write to /proc/self/mem, or using Command to spawn a debugger. These fall outside of the safety guarantees of Rust, and File::open will remain a safe function.


Initial support for the Nintendo 3DS has been added to the Rust standard library. It's not an officially supported platform, so no guarantees, but this should make it easier to develop Rust software for this platform.…


In addition, the Rust compiler can now target Apple's watchOS. This is also an unsupported platform, so no guarantees, but it should now be possible to compile (no_std) Rust code for watchOS. ⌚️

(Support for `std` ships in the next release, 1.64.)…


And that's the end of today's Rust release thread. 🏁

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


Enjoy! ✨🦀


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