Posts tagged with rust

Rust is used for software medical devices

Reading: What does it take to ship Rust in safety-critical?, Rust Blog, 14 January 2026. Rust, the programming language, is already used in safety-critical systems. For example, in IEC 62304 one medical device engineer reports: All of the product code that we deploy to end users and customers is currently in Rust. We do...
Read more

Fast molecule patent checking

One step in drug discovery is a claim on intellectual property. There are various form of this, including rights on data from experiments, but a patent on “composition of matter” is an obvious one. This means, if you’re generating molecules, it would be useful to know if the molecule is subject to a patent—although not...
Read more

Reading a file or stdin with Rust

Sometimes I need a Rust program to accept a filename to read, or default to reading from standard input. Here’s how I’ve ended up doing that: use std::fs::File;use std::io::{BufRead, BufReader};use std::path::PathBuf;trait DefaultToStdin { fn open(&self) -> Box<dyn BufRead>;}That’s defining the shape of what I’m after:...
Read more

URL redirect service in Rust

I’ve accidentally implemented an informally-specified, incomplete, buggy version of mod_rewrite. My excuse is that I didn’t think of that before I’d done the work. Which means I have a tiny piece of Rust code, deployed via a Docker container over at Northflank, to redirect from one domain and blogging URL scheme to a...
Read more

Watching for arbitrary file changes using Bacon

To compile, test, or run Rust code automatically when a file changes, I use cargo watch -c -x run. But in a healthy decision for the Cargo Watch author, the project is over: “It's time to let it go. Use Bacon. Remember Cargo Watch.” The defaults for Bacon and Cargo Watch are different. I noticed this today when...
Read more

UniFFI (at Async JS meet up)

Tonight I was at Async for James talking about uniffi-rs. It’s a tool to generate bindings to Rust code from various other places: Javascript worlds, Python, Kotlin, Swift, others, and now—thanks to James—React Native too. This one slide nicely shows the idea: This is all new to me. It means you can: package up core...
Read more

Adding a sleep to a Rust Axum handler caused a compiler error (puzzler)

To check that a spinner appears and vanishes on a web page, I added a sleep to a request handler to slow it down. My handler then no longer compiles due to a type error. The signature is unchanged. How can adding a sleep do that? I’m using axum and the code is: pub fn routes() -> Router {...
Read more

Coding up a vector symbolic architecture example

I’ve been trying to get my head around VSA (a.k.a hyperdimensional computing). The only way I know how to do that is to write some code, so that’s what I’ve done.The appeal of VSA  the combination of vector representations and an algebra to do some interesting reasoning. The “hyperdimensional” part comes everythng being...
Read more

Rust in critical environments

Reading: Officially Qualified - Ferrocene, Nov 2023. Rust can now be used to develop software for electronic systems in series production road vehicles [… and also] in electronic programmable systems in the industrial sector. Ferrocene is the Rust tool chain (for example, the compiler but not the core libraries), except...
Read more

Rust’s future combinators

The Rust Future module defines many ways to chain and convert futures. This post summarises a few common ones as a reference table. Liberties taken: the result types below are given as Future<T> but this is not accurate. For example, ready returns a Ready<T>, lazy returns a Lazy<T> and so on. But these can be used as if...
Read more

Repeatable and resumable simulations in Rust

I’ve been running simulations that rely on random numbers, and I’m chasing two desirable properties: If I run the same code with the same arguments, I want the same results (whenever possible). I want interrupted runs to pick up from where they left off. In other words, repeatable and resumable code. These are my notes...
Read more

Resources for learning Rust

The other day I was asked to recommend resources for learning the Rust programming language. Here’s what I came up with. How do you like to learn? If you want to type-it-in-the-browser, you have Rust by Example (free). To follow along with a book, using your favourite editor: The Rust Programming Language is “the book”...
Read more

Rust principles

I’m accumulating notes on the principles in Rust. These are the things I want to keep in easy reach to refresh my understanding. Sources The Rust Programming Language, Steve Klabnik and Carol Nichols, with contributions from the Rust Community. Rust by Example. Rust in Motion, Carol Nichols and Jake Goulding, Manning...
Read more

1R in Rust

1R (“one rule”) is a rule learning algorithm that first appeared in 1993. It’s a baseline algorithm: if you can’t do as well as this, you need to think again. This post describes my implementation in Rust. For me, implementing an algorithm is a fun way to improve my knowledge of a language and ecosystem. TL;DR - where’s...
Read more

Combining differing error types

Rust, Scala, and many other languages let you use a kind of or to represent errors. In Scala it might be Either<E, T>, and in Rust it’s likely to be Result<T, E>. The E represents an error, and the awkward part of this is chaining together results with different types for E. This post contains my notes on this, for...
Read more