FP Complete

Owned Values and Futures in Rust Programming

Let’s write a simple tokio-powered program that will download the contents of an HTTP response body using reqwest and print it to stdout. We’ll take the URL to download on the command line using clap. This might look something like the following: use anyhow::Result; use clap::Parser; #[derive(Parser)] struct Opt { url: String, } #[tokio::main] async fn main() -> Result<()> […]

Announcing: pid1 Crate for Easier Rust Docker Images


Introduction The FP Complete team is pleased to announce the release of the pid1 crate, a Rust library for proper signal and zombie reaping of the PID 1 process. When deploying an application in a containerized environment, you typically need to deploy a small init system to forward signals to your application and reap zombies. […]

Rust’s as_ref vs as_deref

What’s wrong with this program? fn main() { let option_name: Option<String> = Some(“Alice”.to_owned()); match option_name { Some(name) => println!(“Name is {}”, name), None => println!(“No name provided”), } println!(“{:?}”, option_name); } The compiler gives us a wonderful error message, including a hint on how to fix it: error[E0382]: borrow of partially moved value: `option_name` –> […]

Cloning a reference and method call syntax in Rust

This semi-surprising corner case came up in some recent Rust training I was giving. I figured a short write-up may help some others in the future. Rust’s language design focuses on ergonomics. The goal is to make common patterns easy to write on a regular basis. This overall works out very well. But occasionally, you […]