Skip to content

lencx/rust-learn-demo

Repository files navigation

Rust

ahead-of-time compiled language

Install & Uninstall

# install
curl https://sh.rustup.rs -sSf | sh

# uninstall
rustup self uninstall

Compiling & Run

# compiling
rustc main.rs

# run
./main

Cargo

[project]
    |-[src]
    |-[target]
    |   |-[debug]
    |   `-[release]
    |-Cargo.lock
    `-Cargo.tomal

Config

Cargo.toml

[package]

name = "package_name"
version = "version_number"
authors = ["your_name <your_email@example.com>"]

[profile.dev]
opt-level = 0

[profile.release]
opt-level = 3

[workspace]
member = [
    "crate_one",
    "crate_two"
]

crate_one/Cargo.toml

crate_two = {path = "../crate_two"}

optimizations(default values)

env opt-level
dev 0
release 3

Building & Running & Test & Doc

# cargo new project_name
# building
cargo build

# cargo new --bin project_name
# running
cargo run

cargo test

cargo doc --open

Building for Release

cargo build --release

Making A New Cargo Project

cargo new project_name
cargo new project_name --bin

Examples

Common Programming Concepts
Ownership
Structs
Enums
Modules
Common Collections
Error handling
Generic Types, Traits, and Lifetimes
Testing
An I/O Project
Functional Features
Cargo
Smart Pointers
Fearless Concurrency
OOP

Releases

No releases published

Packages

No packages published

Languages