4

I'm loading a crate in my project and this crate has a feature called object-pooling that is not thread safe. Someone suggested I remove this functionality from the crate but I don't know how to do that. Is there a special entry that I can add to my Cargo.toml file and disables features from dependencies?

Enthusiast Martin
  • 3,041
  • 2
  • 12
  • 20
Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102

1 Answers1

3

The syntax in your CARGO.TOML is:

crate_name = {version="version_numer", features=[feature1, feature2]}

If you want or don't want to have a specific feature you can adapt the features list.

Check out the crates documentation or sourcecode if you want to know which features provide which functionality.

You can find the available features of your specific crate here: https://github.com/brave/adblock-rust/blob/master/Cargo.toml#L86

Yannick Funk
  • 1,319
  • 10
  • 23
  • 2
    Some features may be enabled by default. These can be disabled using `default-features = false`. More problematically, some of your dependencies may depend on the same version of `adblock-rust` and enable the features you don't want, in which case you don't really have a way to disable them. You can only ensure a feature is _enabled_, not that it is _disabled_. – Sven Marnach Sep 07 '20 at 18:48
  • @SvenMarnach good point, maybe you can add this to my answer – Yannick Funk Sep 07 '20 at 18:50
  • Seems like the right answer - doesn't seem to work for me though but that's another issue I guess. – Romeo Mihalcea Sep 07 '20 at 19:20
  • I don't agree - it basically says "yes there is a way" without actually answering the question! – Martin Bartlett Jul 27 '23 at 09:32