I have a Rust library that implements a lint plugin. I want to include compiletest
, but not require it outside of testing. What is the correct way to specify that the dependency is for testing only?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes. Use dev-dependencies
. From the Cargo docs:
You can add a
[dev-dependencies]
section to yourCargo.toml
whose format is equivalent to[dependencies]
:[dev-dependencies] tempdir = "0.3"
Dev-dependencies are not used when compiling a package for building, but are used for compiling tests, examples, and benchmarks.