Behind the Scenes of Rust String Formatting: format_args!()

The fmt::Argumentstype is one of my favorite types in the Rust standard library.It’s not particularly amazing, but it is a great building block that is indirectly used in nearly every Rust program.This type, together with the format_args!() macro,is the power behind print!(), for … | Continue reading


@blog.m-ou.se | 4 months ago

Rust temporary lifetimes and "super let"

The lifetime of temporaries in Rust is a complicated but often ignored topic. In simple cases, Rust keeps temporaries around for exactly long enough, such that we don’t have to think about them. However, there are plenty of cases were we might not get exactly what we want, right … | Continue reading


@blog.m-ou.se | 4 months ago

Do we need a "Rust Standard"?

Languages like C and C++ are standardized.They are fully specified in an internationally recognized standards document.Languages like Python, Swift and Rust do not have such a standards document.Should Rust be standardized? Why, or why not?In this blog post, I try to explain why … | Continue reading


@blog.m-ou.se | 1 year ago

Comparing Rust's and C++'s Concurrency Library

The concurrency features that are included in the Rust standard libraryare quite similar to what was available in C++11: threads, atomics, mutexes, condition variables, and so on.In the past few years, however, C++ has gained quite a few new concurrency relatedfeatures as part C+ … | Continue reading


@blog.m-ou.se | 1 year ago

Rust Is Not a Company

Last year, as an occasional contributor to the Rust project, I did not thinkmuch about the organisational structure of the team behind the project. I saw ahierarchy of teams and groups, team leaders, etc. Just like any otherorganisation. This year, after getting more involved, be … | Continue reading


@blog.m-ou.se | 2 years ago

Writing Python inside your Rust code – Part 4

In this final part of the series,we’ll explore a trick to make the behaviour of a macro dependon whether it’s used as a statement or as part of an expression.Using that, we’ll make the python!{} macromore flexible to allow saving, reusing, and inspecting Python variables. | Continue reading


@blog.m-ou.se | 3 years ago

Writing Python inside your Rust code – Part 3

Have you ever seen the Rust compiler give a Python error? Or better, have you ever seen rust-analyzer complain about Python syntax? In this post, we’ll extend our python!{} macro to make that happen. | Continue reading


@blog.m-ou.se | 3 years ago

Writing Python inside your Rust code — Part 2

In this part, we’ll extend our python!{}-macro to be able to seamlessly use Rust variables in the Python code within. We explore a few options, and implement two alternatives. | Continue reading


@blog.m-ou.se | 3 years ago

Writing Python inside your Rust code — Part 1A

Before continuing to extend our python!{} macro in part 2, let’s explore some things in more detail first. | Continue reading


@blog.m-ou.se | 4 years ago

Writing Python inside your Rust code

About a year ago, I published a Rust crate called inline-python,which allows you to easily mix some Python into your Rust code using a python!{ .. } macro.In this series, I’ll go through the process of developing this crate from scratch. | Continue reading


@blog.m-ou.se | 4 years ago

Compile time unit arithmetic in C++

In Software for Infrastructure,Bjarne Stroustrup shows a way to use templates to make the C++ compileraware of the unit of a value (e.g. kilograms, seconds, etc.), such that it can check consistent useand prevent disasters like the well knownerror at NASA in 1999caused by mixing … | Continue reading


@blog.m-ou.se | 10 years ago

C++11: Rvalue references for *this

Recently, gcc added support rvalue references for *this. (Clang has supported it for quite a while now.) In this post, I show how to use this feature, and how it means we can finally define accessors and a few other things like operator= correctly. | Continue reading


@blog.m-ou.se | 10 years ago