Learning Rust, week 2By Kunal Mehta
I think I'm starting to understand why people like Rust so much. The tooling, especially
cargo are pretty fantastic. The fact that
rustfmt (code auto-formatter),
clippy (linter) and a test runner are all integrated through
cargo is super convenient. I feel like Python used to have that with
setup.py but over time that's been lost.
This week I ported my Gerrit helper grr to Rust, and wrote a Reddit downloader tool, subdown3, that I originally wrote in Python nearly a decade ago. subdown3 has straightforward command-line options and primarily deals with URL parsing and hitting various APIs. grr is a convenience wrapper around git that just shells out.
I'm also hosting my Rust projects on GitLab, primarily to take advantage of its CI features (which I don't feel like setting up for git.legoktm.com). I've been using cargo-tarpaulin to generate coverage for tests, which has been simple. No extra configuration or anything, you just run it.
One thing I've been struggling with is figuring out how to mock functions. Because grr primarily shells out to git, integration testing isn't that useful, but testing what exactly we're shelling out to is more useful.
- publishing stuff on crates.io