logoalt Hacker News

masklinntoday at 11:05 AM2 repliesview on HN

The fun part is it is pretty easy to “rewrite” ripgrep in rust, because burntsushi wrote it as a ton of crates which you can reuse. So you can reuse this to build your own with blackjack and hookers.


Replies

SAI_Peregrinustoday at 2:16 PM

A "ton of crates" is IMO the best way to write large Rust programs. Each crate in Rust is a compilation unit, the equivalent of one `.c` file in C. If they don't depend on one another, each crate can be compiled in parallel. It makes building the whole project faster, often significantly so. As with anything one can take it too far, but as long as each crate makes sense as an independent unit it's good.

show 1 reply
mijoharastoday at 1:24 PM

Gotta add a +1 for this. I wanted to do some ignore files etc for a project.

I thought "well I kinda want to do what rg does". Had a little glance and it was already nicely extracted into a separate crate that was a dream to use.

Thanks @BurntSushi!