The Rustacean Station Podcast

This Week in Rust - Issue 348

Episode Page with Show Notes

Nell Shamrell-Harrington: Greetings, everyone! Welcome to this week’s episode of This Week in Rust on the Rustacean Station. As always, I’m Nell Shamrell-Harrington, lead editor of This Week in Rust and also a Sr. Staff Research Engineer on the Rust team at Mozilla.

This episode covers issue #348 of the This Week in Rust newsletter, published on July 20, 2020.

First, this week’s Rust news.

A new version of Rust has been released — version 1.45.0. This release includes 2 major changes. The first is to fix unsoundness when casting between integers and floats. The second major change is stabilization of function-like procedural macros in item positions. This means you can now invoke procedural macros in three new places — expression position, pattern position, and statement position. This is a big gift to fans of the Rocket web framework! This means it can now be compiled using stable Rust! I hope this causes Rocket to ignite and I can’t wait to see where it goes.

Olivia Ifrim has released a new md book called “Rust Sokoban.” Check out this book to learn about the Rust gamedev ecosystem as you create a copy of the Sokoban game in Rust.

When I was a Rust beginner a few years ago, I remember at first being a little confused regarding how Rust modules work. If you are in or have ever been in that position, Sheshbabu Chinnakonda has written a great intro called “Clear Explanation of Rust’s module system.” It includes lots of information on how to best structure modules in your Rust code base.

This next article is close to my heart, as my first professional programming experience was working for the Physics department at the University of Washington. Ferdia McKeogh has published an article called “Rewriting FORTRAN Software in Rust” — you will still encounter FORTRAN code a lot in academia. When the author was an undergrad research assistant, they were tasked with parallelizing a piece of shallow water simulation software. They rewrote it in Rust to gain the memory safety, thread safety, and data race guarantees of the Rust language. Give the article a read for the why and how.

Next up are a couple of articles related to the Rust ecosystem for Windows. The first is an article by Matthias — titled “Writing a kernel driver for Rust.” The article goes through how they rewrote a Windows Kernel driver — which was originally written in C++ — in Rust. Learn how they set up the project, extended the linker search path, created Rust bindings to the Windows kernel, ran and signed the driver, and the mistakes, errors, and problems they encountered along the way.

Also on the topic of Windows, Ryan Gorup — the founder of Ebbflow — published “Packing and Vendoring Production Rust Software in Windows”. This post discusses how Ebbflow vendors it’s client — which is written in Rust — to Windows users. They use the windows-service crate to provide the interface needed for the Windows Service framework. Check out the article for more information about how they statically linked Microsoft Visual C++ — because it turns out it is not included in the Windows 10 image, as well as how they built the msi installer using Wix, automated their builds through GitHub actions, and distributed the package through both Chocolatey — a 3rd party package manager for Windows — and Winget — a first party package manager for Windows that is currently in preview.

If you have been interested in async rust, but found it intimidating, Daniel Cook has written an article specifically geared toward you titled “Async Rust, but less intimidating”. It is a clear tutorial and explanation of Async concepts in Rust and a guide to combining futures into reusable function chains using the futures-util crate.

A few videos were published this week.

The first is called “Rust: What is Ownership and Borrowing” on the Gary Explains YouTube channel. It covers ownership and borrowing and, in the words of the video description, “It can be a little tricky to understand, but once you do you will understand why Rust is called a memory safe language.”

Ryan Levick has posted another fantastic stream called “Boiled Down Crate: OnceCell.” Watch the video to see Ryan recreating the OnceCell crate, a simple utility crate for initializing a value once.

I’m also happy to feature a Portuguese language stream on Rust from the CodeShow channel on Twitch. It is part 4 of a Rust course and focuses on strings and matching.

Moving on to calls for participation, this week we have four projects looking for contributors. These include the zbus project — which is a Rust implementation of the D-Bus protocol. The D-bus protocol is a way for applications to talk to one another. Zbus provides two APIs. The first is used to send and receive messages over a connection. The second API is used to interact with peers through high-level concepts like method calls, signals, and properties.

Other projects looking for contributors include the just project, which is a handy way to save and run project-specific commands, the libpnet project, which is a cross platform API for lower level networking using Rust, and the Rust project itself.

If you have wanted to get involved in open source Rust development but haven’t known where to start, definitely check out these projects and get your pull requests in.

Now let’s focus on this week in RFCs.

No RFCs were approved this week.

One RFC was moved into final comment period. This RFC is titled “RFC: C unwind ABI.” We previously covered it on this podcast when it was opened. To recap:

Unwinding is what happens when a program you are running throws an exception. When the exception is thrown, the runtime for the program will unwind the stack and essentially traverse backward through it, calling any clean up or error recovery code.

Rust does not implement exceptions the way languages like C++ do, but it does support unwinding under two conditions. When rust code panics, it will unwind the stack. Also when Rust is interfacing with another programming language that does implement exceptions — such as C++ — it can also call functions in that language to unwind the stack.

Currently, when foreign code — that means code not written in Rust — calls Rust code and the Rust code panics, the foreign code cannot unwind that Rust panic. Likewise, when Rust calls foreign code and that code throws an exception, Rust cannot unwind what happened in that code.

This RFC seeks to change this by defining a new ABI string as an addition to the current ABI. An ABI is an application binary interface — it’s a way for two compiled binaries to interact with each other. The ABI string defined by this RFC makes it safe to unwind C++ frames with a Rust panic and unwind Rust frames with a C++ exception.

For more details and examples, make sure to read the full RFC.

Five new RFCs were proposed this week.

The first, titled “Add oneof configuration predicate to support exclusive features”, [BREATH] has to do with configuration macros. If adopted and implemented, it would allow someone to use a configuration macro to specify that one of a list of features must be active, rather than all the features in the list.

The second new RFC, called “Promote aarch64-unknown-linux-gnu”, concerns the Arm Arch 64 platform. Arch64-unknown-linux-gnu is currently a Tier 2 Rust target. Tier 2 platforms can be thought of as “guaranteed to build”, but not necessarily to work. This RFC proposes promoting this platform to a Tier 1 Rust target. Tier 1 platforms can be thought of as “guaranteed to work”. Check out the RFC for more information on what makes this platform ready to be considered Tier 1.

The third new RFC is titled “Add Drop::poll_drop_ready for asynchronous destructors”. It proposes adding a new method to the Drop trait called poll_drop_ready. When a value is dropped within an async function or block, it’s poll_drop_ready method will be called repeatedly until it returns Poll::Ready, which means the async operation is complete. Then the drop method will be called. This way, users can perform non-blocking operations during destructors when they are called in an async context.

The fourth new RFC is called “Stabilize Cargo’s new feature resolver”. There is currently a new feature resolver available for Cargo in the nightly channel as an unstable feature. This RFC proposes promoting it to a stable feature. Read the RFC for an explanation on what the feature is and where future work might take it.

Finally, the fifth new RFC is titled “Add the partial-closure-args RFC”. Currently, when you are dealing with a Rust tuple or struct has many fields, you can use the 2 dots syntax to use only a few of those fields and ignore the rest. This RFC proposes using this syntax with arguments to closures. It would allow a program to easily use only the arguments it needs and ignore the rest.

Thank you so much to everyone who has taken the time to open RFCs - they are how the Rust community has grown and flourished over the past few years.

There are several Rust job openings featured in this week’s newsletter. These include engineering positions at LogDNA, Electron, Noibu, OneSignal, OnePassword, Findora, ESR Labs, and a teaching position at the University of Paris. See the newsletter for links to the posting and all the details.

As for Rust events, we have an upcoming online meetup in Berlin, Germany as well as the Rusty Days Virtual Rust Conference from July 27-August 8. I will be speaking at that one and introducing you to the internals of the Rust compiler and, in particular, the borrow checker. Additionally, in person Rust meetups are being held in Durham, North Carolina, Dallas, Texas, and Auckland, New Zealand.

And that’s all for this podcast. Make sure to read the newsletter for even more great Rust content.

This Week in Rust is edited by myself, Andre Bogus, and Colton Donnelly. This week’s contributors included, using their GitHub usernames, jdrouet, crd499, gterzian, dodomorandi, and hmble.

As always, if you write a great article on Rust or happen to see one — please submit it to This Week in Rust by opening a pull request on our GitHub repo. Have a wonderful week everyone and please take care!