Rust - Multithreading - ABBA deadlock with Arc, Mutex and OS Thread

Your program compiles, runs, prints nothing, and simply sits there forever. Welcome to the deadlock club, the most silent bug family in concurrent programming. In this tutorial we build the most classic deadlock of all, the lock ordering deadlock, also known as the ABBA deadlock. Our playground: two embedded bus devices, SPI and I2C, each protected by its own Mutex. Two threads transfer data between the buses in opposite directions, each locking its source first. ...

July 8, 2026 · Mi-K

Rust - CLI - Validate program arguments and handle errors with an enum and test suite

A command line program always starts with the same question: what did the user actually pass in, and can I work with that? In this tutorial we’re going to see how to handle user arguments and how to test them through unit tests and integration tests. What we need GitHub for this tutorial: https://github.com/badprog/badprog-rust-cli-validate-program-arguments-and-handle-errors-with-an-enum-and-test-suite/tree/v1 rustc 1.96.0 (ac68faa20 2026-05-25) Docker VSCode with the Dev Containers extension Project structure . |-- Cargo.lock |-- Cargo.toml |-- src | |-- core | | `-- arg_analyzer.rs | |-- core.rs | |-- file | | `-- bp.txt | |-- main.rs | |-- utils | | `-- errors.rs | `-- utils.rs `-- tests `-- integration.rs main.rs main() fn main() -> ExitCode main.rs is kept separate from the rest of the project on purpose. ...

June 28, 2026 · Mi-K

Rust - Crate - Grcov demo

When your projects grow complex, ensuring that every single line of code is covered by your tests becomes critical. But how do you verify such a thing efficiently? Fortunately, the Rust ecosystem offers powerful crates for this purpose. This tutorial will guide you through setting up grcov for reliable code coverage. First of all The complete source code for this tutorial is available on GitHub: https://github.com/badprog/badprog-grcov-demo All required software will be installed within our Docker environment (Dockerfile). ...

November 23, 2025 · Mi-K

Rust - Python binding - Setting up PyO3 crate with Maturin

When you want to make large computations, using Python may not be the best solution. By building a Python module from Rust, we get the best of both worlds: Python productivity and Rust speed. In this tutorial we’ll cover the basic integration process using PyO3, a Rust crate, for the bindings and Maturin, a Python tool,for managing the dynamic library. First of all Github of this tutorial: https://github.com/badprog/badprog-rust-binding-python-with-pyo3 And versions used: ...

November 2, 2025 · Mi-K

Rust - Exploration - Adding memory and performance mode to the Vec struct

The original Rust Vec struct is already a fantastic growable array, easy to use. But what about adding a mode enabling to choose between memory and performance? Furthermore it’s a good way to understand why capacity and len aren’t the same thing. Let’s see that in this tutorial. First of all You can find the source code on my Github: https://github.com/badprog/badprog_vec_plus Memory vs performance Sometimes you have to make a choice: memory or performance. ...

September 14, 2025 · Mi-K