I have the following project structure:
.
├── Cargo.toml
└── task1
├── Cargo.toml
├── src
│ ├── main.rs
│ ├── resources.rs
│ └── users.rs
└── tests
└── task1.rs
./Cargo.toml:
[workspace]
members= ["task1"]
and ./task1/Cargo.toml:
[package]
name = "task1"
version = "0.1.0"
[dependencies]
rand = "0.8.5"
where users.rs uses functions from rand: use rand;
Although I've structured this, following https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html, it seems the rand package is not being detected by users.rs anyways when I build (unresolved import `rand`
).
Not sure how to solve this, or if it's unsolvable what's the best workaround. I intend to have more packages besides task1 aswell.
When you don't include the edition, it defaults to 2015. Automatic extern crate
was added in edition 2018. You should always use the latest edition for new projects. Projects generated with cargo new
or cargo init
will always include the edition.
[package]
name = "task1"
version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"