logoalt Hacker News

xvedejasyesterday at 4:44 PM2 repliesview on HN

Does this take into account feature flags when summing LOC? It's common practice in Rust to really only use a subset of a dependency, controlled by compile-time flags.


Replies

saghmyesterday at 11:10 PM

My experience has been that while there's significant granularity in terms of features, in practice very few people actively go out of their way to prune the default set because the ergonomics are kind of terrible, and whether or not the default feature set is practically empty or pulls in tons of stuff varies considerably. I felt strongly enough about this that I wrote up my only blog post on this a bit over a year ago, and I think most of it still applies: https://saghm.com/cargo-features-rust-compile-times/

gsneddersyesterday at 5:42 PM

Also just unit tests in the source files, which again aren’t included in the binary via compile-time flags!