Use Cargo.toml to define your project's dependencies and settings, and let Cargo.lock automatically record the exact versions resolved for reproducible builds. You edit Cargo.toml to add or change dependencies, while Cargo.lock is generated by Cargo and should be committed to version control to ensure everyone builds with the same dependency tree.
[package]
name = "your-project"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = "1.0"
cargo build
Cargo.lock is created automatically after the first build and contains the precise versions of all dependencies and their transitive dependencies.