pestanko / ct-rust-demo

Rust Demo for the Learning session

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CT Rust Demo

Rust Demo for the Learning session

Getting Started

Install the Rust using the Rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Working with the Rustup

Update the rust version(s):

rustup update

For more information (for example install the nightly version of rust), take a look here.

Cargo (package manager)

Cargo is the Rust package manager. Cargo downloads your Rust package's dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community’s package registry. You can contribute to this book on GitHub.

Create a new package

Official documentation

# --bin is default (you will be creating an executable binary)
cargo new --bin my-ultimate-app
# --lib is for libraries
cargo new --lib my-ultimate-lib

Run the tests:

cargo test

Run the main.rs (for binary only):

cargo run

Add a dependency to your project - there are 2 options, you can either manually edit: Cargo.toml or run cargo add

Edit the Cargo.toml file:

[dependencies]
serde = { version = "1.0.152", features = ["derive"] }

Run the cargo add:

cargo add serde
# or with features
cargo add serde --features derive

Rust-Analyzer (LSP)

Install the rust-analyzer:

Clippy (linter)

To use Clippy, you need to install it using the Rustup:

rustup component add clippy

Then you can run it:

cargo clippy
# or with fix
cargo clippy --fix

Other tools

For other tools and components take a look:

Online learning resources

About

Rust Demo for the Learning session

License:MIT License