🦀Cargo
Describe about Cargo
Cargo is the package manager of Rust programming like maven
or npm
.
Command:
cargo init
= CreateCargo.toml
like a package.json of Rustcargo new <project_name>
= Create the boilerplate of project includingCargo.toml
andsrc
folder that containmain.rs
cargo build
= Compile the project and create executable file intarget/debug/executeable
but for release you can use commandcargo build --release
it will create intarget/release/executeable
cargo run
= It will compile and run the executable file.cargo update
= It will update the dependencies and ignoreCargo.lock
file.cargo check
= It is to check for project can compile or not , use this command instead build to prevent step to create executable file and to ensure the code can compile.
File Structure
Cargo.toml
-> It will store the detail of the project like package.json
Cargo.lock
-> It will store detail of dependencies that use in this project and version of it. In case that you clone this project in the future and your old dependencies is too old but new version will break the code when you use cargo to build it will always use the version of Cargo.lock instead to prevent this problem and you can update it manually for new version.
src/main.rs
-> Main class of Rust to run the application
Last updated