Home›Discover›Programming›Mara Bos

Mara Bos

Posts per week · about 00 subscribersenProgramming
blog.m-ou.se

Recent articles

Subscribe and these — and every new article — show up in your reader

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

AI summaryThis blog post explores Rust's fmt::Arguments type and the format_args!() macro, which power common text formatting macros such as print!(), format!(), and log::info!(). The author describes fmt::Arguments as a great building block that is indirectly used in nearly every Rust program. The post covers how it works, how it is implemented today, and how it might change in the future.

Rust Temporary Lifetimes and "Super Let"

AI summaryThis article explores the complicated and often overlooked topic of temporary lifetimes in Rust, noting that while simple cases work automatically, there are many situations where temporaries don't last exactly as long as desired. The authors rediscover the rules governing temporary lifetimes, examine several use cases for temporary lifetime extension, and introduce a proposed new language feature called 'super let' that would give developers more control over temporary lifetimes.

Do we need a "Rust Standard"?

AI summaryThis blog post examines whether Rust should receive a formal standards document like those that exist for C and C++. The author argues that while Rust needs an accurate specification, full 'standardization' may not be necessary depending on how it is defined. The post also provides an overview of the current state of Rust's stability guarantees and specification efforts.

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

AI summaryThe article compares Rust's concurrency library with C++'s, noting that Rust's standard library features—threads, atomics, mutexes, and condition variables—closely resemble those introduced in C++11. C++ has since gained additional concurrency features through C++17 and C++20, with more proposals for future versions. The article reviews these C++ features, discusses what Rust equivalents could look like, and what it would take to implement them.

Converting Integers to Floats Using Hyperfocus

AI summaryThe author recounts how, through an unexpected chain of events, they implemented a conversion from 128-bit integers to 64-bit floats that turned out to be faster than the built-in conversion of every compiler they tested. The blog post explains what happened, how floats work, how the conversion functions, and how the project got a bit out of hand.

Rust is not a Company

AI summaryThe author, a contributor to the Rust project, initially perceived the project's hierarchy of teams and leaders as just another typical organizational structure. After becoming more involved—joining the library team and eventually becoming its team lead—they started reflecting more deeply on why this structure exists and what purpose these teams actually serve.

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, reusi

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.

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.

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.

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.

Compile time unit arithmetic in C++

AI summaryThe article builds on Bjarne Stroustrup's technique from Software for Infrastructure, which uses C++ templates to make the compiler aware of value units, allowing it to verify consistent usage and prevent disasters like NASA's 1999 unit-mixing error. The author extends this idea to support any number of base units and linearly related units (such as centimetres, metres, and inches) by teaching the compiler to perform arithmetic on units at compile time.

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= co