In a Cargo.toml manifest, what is the difference between the two types of dependencies? It seems that the "dev" dependency is conditional / invoked at a certain time only.
If I include a crate under [dev-dependencies]
and try to use it in my code, it gives me an error:
[package]
# ... snipped ...
[dependencies]
# no uuid here
[dev-dependencies]
uuid = "1.0.0"
use uuid::Uuid;
fn main() {
println!("Hello, world!");
}
error[E0432]: unresolved import `uuid`
--> src/main.rs:1:5
|
1 | use uuid::Uuid;
| ^^^^ use of undeclared crate or module `uuid`
But if I move it under [dependency]
, then there is no error. If the "dev" dependencies aren't used in my code, where are they used?
They are dependencies that only get included / built for examples, tests, and benchmarks. They will not be included when you run a simple cargo build
.
See development dependencies in the Cargo Book.