learn-rust is a package. a crate is a binary or library. a package can have a library crate (lib.rs) and multiple binary crates (main.rs, bin/*.rs, bin/*/main.rs). (need at least one library or binary crate. a workspace can have multiple packages as members.
https://doc.rust-lang.org/stable/cargo/
https://doc.rust-lang.org/stable/cargo/reference/config.html https://doc.rust-lang.org/stable/cargo/reference/environment-variables.html
sh
cargo init --bin # for binary(executable) crate
cargo init --lib # for library crate
src/main.rs
sh
cargo run
src/bin
directory.src/main.rs
src/bin/another_executable.rs
src/bin/multi_files_executable/main.rs
default-run
in Cargo.tomlcargo run
without --bin
option.```sh cargo run --bin learn-rust # to run main.rs cargo run --bin anotherexecutable # to run bin/anotherexecutable.rs cargo run --bin multifilesexecutable
cargo run # = cargo run --bin learn-rust (when default-run = learn-rust) ```
sh
cargo run --release
sh
cargo new --lib another_crate
https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
sh
cargo doc --open
sh
cargo clean
sh
cargo check
https://doc.rust-lang.org/cargo/reference/publishing.html