Pieces tagged with: rust

April 14, 2022

rust

Cargo modules

Today I learned about the cargo-modules, a cargo plugin which shows you an overview of your crates modules.

I like to check the tree and my public interface with:

cargo modules generate tree --with-types

August 1, 2021

rust

Add aliases for your Rust project

I was looking at the Monkey language implementation done by Lauren Tan and noticed a .cargo/config.toml file in the project directory. In it was a convenient alias for her project:

dev = "watch -x check -x test"

This way, we can run cargo dev, which will run a check, which is not a build but catches a lot of errors quickly. The test is for those doing TDD because it will run the tests after every change. Convenient!

Rust project templates

Rust never stops to amaze me with its command-line tools and today I found out about cargo-generate which enables you to setup a repository which will function as a project template for Rust.

As an example, to pull down the repository and start a new project, you would do:

cargo generate --git https://github.com/githubusername/mytemplate.git --name myproject

Staying up-to-date with Rust

I have this tick where I continuously check that my tools are running the latest version. I guess you could call it a form of FOMO.

Luckily, Rust has me covered with two packages which check that for me.

cargo-outdated which check that your project dependenies are up-to-date. And cargo-update which checks that your Rust executables, like cargo-edit are running the latest version.

It will even update itself!

May 24, 2021

rust

Rust tooling came a long way

I bought the Hands-on Rust and needed to setup my editor (Visual Studio Code) to start working on my 2D dungeon crawler. Choose Rust Analyzer and could not be more impressed with the experience.

Also impressed with some of the Cargo helper tools, like cargo-edit to manage dependencies, cargo-audit to check for vulnerabilities and cargo-expand to expand macro's.

2021 is a great year to start learning Rust. Both the ecosystem and learning materials have reached a high level of maturity.