Table of contents
Open Table of contents
Rust language installation
For my rust learning, I’m using rustup to install rust and its toolschain e.g. Cargo
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
To update rust, simply running following commands
rustup upgrade
What is Cargo ?
Cargo is pacakge manager (just like NPM to NodeJS)
Install cargo package
cargo install cargo-edit
cargo install cargo-watch
cargo install cargo-audit
How to use Cargo package manager
# Init application <name>
cargo init <name>
# Build and run app
cargo run
# Watch for changes and rebuild
cargo watch
# Run tests
cargo test
# Build a release without debug info
cargo build --release
# Add/Remove package <pkg> to app
cargo add <pkg>
cargo rm <pkg>
Bonus, Add Tokio to the app (Tokio is an asynchronous runtime for Rust)
cargo add tokio