Hacking together a CLI with Rust
I’m supposed to be writing a mathematics thesis at Reed at the moment, which involves the minor tedium of collecting citation data into BibTeX. Naturally, this seemed like a great opportunity to halt all important work and start a little side project :)
I hacked together a tool to assist collecting BibTeX citations. It works like this:
The program is quite simple, but was fun to build as a first project in Rust. A few notes about the Rust learning experience:
Rust has an incredible package ecosystem, largely enabled by Cargo. After reading the first few chapters of the book, it was easy to wire up some plumbing between various crates to get a working prototype very rapidly. For example, I use the scraper crate to scrape publication data from MathSciNet. The scraper package uses Servo under the hood, which unlocks browser-grade parsing and querying with very little effort!
The Rust compiler is infamously fickle. While I did receive lots of bewildering feedback from the compiler along the way, I found this to be a nice feedback loop around which to organize my development workflow. The feedback loop felt similar to TDD.
I was pleasantly surprised to find how ergonomic and comprehensive error handling is in Rust—this is perhaps my favorite aspect of the language so far. It’s kinda like error handling in Go, except it feels less ad-hoc.
I plan to work on this project a little more. I want to make the code more idiomatic, and perhaps make the tool pluggable next for multiple citation databases.