Additional features for dev-dependencies

Is there a way to use certain features only for dev-dependencies builds?

I'm looking to do something like this:

tokio = { version = "1" }

tokio = { version = "1", features = ["macros"] }

If I recall correctly this doesn't actually work as one might expect; doesn't it use the union of all features from all sections?

Also, I'm unhappy about specifying the version twice.

Is there some way to specify different features for dependencies and dev-dependencies?

A while back I saw someone mention that how features are specified is being reworked. Is that still happening, and is there a good place to track this (and provide input)?

What you wrote should work fine. I use it in the Tokio codebase, e.g. here is a snippet from tokio-util:

tokio = { version = "1.0.0", path = "../tokio" }

tokio = { version = "1.0.0", path = "../tokio", features = ["full"] }
1 Like

That will still use the union of all features across dependencies and dev-dependencies within your project.

The new feature resolver is being stabilized though, which will allow different feature sets between dependencies and dev-dependencies. See the stabilization PR

1 Like

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.