I'm new to Rust and compiled languages in general. Does every crate I include as a dependency end up in the binary, even if I don't use a single function from that crate?
And if I use just a single function from a big library. Does the entire library get compiled or only that function and whatever that function requires?
In Javascript, there is tree shaking, to eliminate dead code without having any downside other than extra time to shake the tree. Does an equivalent exist for Rust? After all, Clippy is good at finding dead code, so it should be able to just not compile and include in the binary.
I know that it's possible to optimize for binary size using opt = 'z'
, but that comes at the cost of slower execution.