Let’s write a little exchange rate viewer in Rust. It will have a GUI, fetch rates from the Internet, support changing the currencies without having to recompile, and all this in about 200 lines of code.
Let’s write a little exchange rate viewer in Rust. It will have a GUI, fetch rates from the Internet, support changing the currencies without having to recompile, and all this in about 200 lines of code.
While writing the nix-nar
crate, I had to bend Rust’s Iterator
API to do things it wasn’t designed for. The resulting code looks strange, so let’s walk through increasingly complex implementations to see why it has to be that way.
If we try to open an HTTPS connection with ureq
, and the host part of the URL is an IP address, then we get an InvalidDNSNameError
. Let’s figure out what’s going on and how to work around it.
It’s occasionally useful to introduce pause points into procedures. The idea is that, when a human operator is about to do something scary, we want them to stop and think for a second and not just do things by rote. Enter challenge-prompt
, a small program and Rust library which challenges the user to type something.