Mara Bos

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

    The fmt::Arguments type 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!(), format!(), log::info…

    Published

  2. 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 away. In this post, we…

    Published

  3. 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 I do think we need…

    Published

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

    The concurrency features that are included in the Rust standard library are 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 related features as part C++17 and C++20, with…

    Published

  5. Converting Integers to Floats Using Hyperfocus

    A few years ago, due to some random chain of events, I ended up implementing a conversion from 128 bit integers to 64 bit floats. This would’ve turned out to be a complete waste of time, except that my final version is faster than the builtin conversion of every compiler I tested. In this blog post,…

    Published

  6. Rust is not a Company

    Last year, as an occasional contributor to the Rust project, I did not think much about the organisational structure of the team behind the project. I saw a hierarchy of teams and groups, team leaders, etc. Just like any other organisation. This year, after getting more involved, becoming a library team…

    Published

  7. 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 depend on whether it’s used as a statement or as part of an expression. Using that, we’ll make the python!{} macro more flexible to allow saving, reusing, and inspecting Python variables.

    Published

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

    Published

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

    Published

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

    Published

  11. Writing Python inside your Rust code — Part 1

    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.

    Published

  12. Compile time unit arithmetic in C++

    In Software for Infrastructure, Bjarne Stroustrup shows a way to use templates to make the C++ compiler aware of the unit of a value (e.g. kilograms, seconds, etc.), such that it can check consistent use and prevent disasters like the well known error at NASA in 1999 caused by mixing incompatible units…

    Published

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

    Published