Skip to content

pollyolly/RUST-NOTES

Repository files navigation

RUST-NOTES

M1 Installation

https://www.rust-lang.org/tools/install
$curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Check Rust Installation

$which rustc
$which cargo

Running Rust File in Commandline

Run in Debug Mode

$rustc test.rs

Optimized Compilation of Rust file

$rustc -O test.rs

Run the Debug or Compiled Rust file

$./test

Cargo

Creating Rust Cargo Project

$cargo new rust-jwt

Creating Rust Cargo Binary Program

$cargo new sample_progra --bin

#To Run
$cargo run --bin server
#Cargo.toml
[package]
name = "rust-grpc-chat-auth"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "server"
path = "src/server.rs"

[[bin]]
name ="client"
path = "src/client.rs"

Creating Rust Cargo library for Python

$cd proj_dir
$cargo new "library_name" --lib
#Cargo.toml
[package]
name = "pyo3"
version = "0.1.0"
edition = "2021"

[lib]
name = "calculate_pi"
create-type = ["cdylib"]

Cargo Clean and Release Build

$cargo clean
$cargo build --release
//Build Location
$cd rust-project/target/debug/rust-project-name

//Execute The Project
$./rust-project-name

Cargo Hot Reload

$cargo install cargo-watch

To run

$cargo watch -x run

Remove Library

$cargo remove <library>

Troubleshoot

Fix Ambiguous Library

Check the library tree

$cargo tree -p axum

Check Cargo.lock to confirm duplicate

$vim Cargo.lock

Then Re-add the library specifying the version

 $cargo add axum@0.8.1

Reference

Shuttle Rs Tutorials

Rust Lang Nursery

Google Rust Tutorial Documentation

Rust Book

Rust Async/Await Book

Tokio Runtime

Recommended by Lets get rusty

Rust by example

Rust by Practice

Lets Get Rusty

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages