Are optional dependencies always included in the final binary?

Read from dependencies, I'm planning to use "features" and "optional dependencies" to export different components of a project. I'd like to know when I turn on parts of features, whether the library size narrowed as much as possible.

See also this thread for more details.

Disabled optional dependencies are not included in the binary.

Enabled optional dependencies may or may not. If you use lto setting, then unused code will be mostly removed, so unused dependencies may end up being removed.

3 Likes

Thank you and I just notice I can do an experiment locally :stuck_out_tongue:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.