Creating a Workspace
Create the Root Project Directory
mkdir project_name
cd project_nameCreate a Cargo.toml in Project Root
[workspace]
members = [
"project_library",
"project_app"
]Use cargo to Create the Packages
cargo new project_library --lib
cargo new project_app --binDependencies Between Packages
In this example, the
project_appcrate will depend on theproject_librarycrate.
Edit <project_root>/project_app/Cargo.toml
[dependencies]
project_library = { path = "../project_library" }Bringing project_library Code into Scope
<project_root>/project_app/src/main.rs
use project_library; // Bring project_library into scope
fn main() {
project_library::func(); // Can now call function within project_library
}