All articles

RFC: Pass pointers to const in assembly

The const operand to asm! and global_asm! currently only accepts integers. Change it to also accept pointer values. The value must be computed during const evaluation. The operand expands to the name of the symbol that the pointer references, plus an integer offset when necessary.

Continue Reading

RFC: Target Modifiers

This RFC introduces the concept of "target modifiers," flags that can cause unsoundness if compilation units disagree on them. We propose failing the build if rustc detects disjoint target modifier sets between units, with an escape hatch (-Cunsafe-allow-abi-mismatch) available. This RFC does not stabilize any specific modifiers but establishes the framework for handling them.

Continue Reading

RFC: #[derive(SmartPointer)]

Make it possible to define custom smart pointers that work with trait objects. For now, it will only be possible to do this using a derive macro, as we do not stabilize the underlying traits.

Continue Reading

Actors with Tokio

This article is about building actors with Tokio directly, without using any actor libraries such as Actix. This turns out to be rather easy to do, however there are some details you should be aware of:

  1. Where to put the tokio::spawn call.
  2. Struct with run method vs bare function.
  3. Handles to the actor.
  4. Backpressure and bounded channels.
  5. Graceful shutdown.

The techniques outlined in this article should work with any executor, but for simplicity we will only talk about Tokio. There is some overlap with the spawning and channel chapters from the Tokio tutorial, and I recommend also reading those chapters.

Continue Reading

Async: What is blocking?

The async/await feature in Rust is implemented using a mechanism known as cooperative scheduling, and this has some important consequences for people who write asynchronous Rust code.

The intended audience of this blog post is new users of async Rust. I will be using the Tokio runtime for the examples, but the points raised here apply to any asynchronous runtime.

If you remember only one thing from this article, this should be it:

Async code should never spend a long time without reaching an .await.

Continue Reading

The Game of Life on a PCB

I've created a printed circuit board (PCB) that simulates the game of life on a 5 by 5 LED grid, and can be remote controlled with Bluetooth. The project was created in collaboration with another student as a school project. Here is a video of the finished product:

Continue Reading