profileRyan KesPGP keyI build stuffEmailGithubTwitterLast.fmMastodon

Rust

#+tags: namepage

Description

Notes from reading The Rust Programming Language

Language

Getting Started

Hello World example

fn main() {
    println!("Hello, world!");
}
  1. Functions & Macros

    println! calls a Rust Macro. Functions don't include the ! (ie println).

  2. Rustc

    Rustc handles Rust compilation rustc main.rs

  3. Cargo

    Cargo is Rust's build system and package manager

    1. Cargo commands

      1. Create project

        cargo new hello_cargo
      2. Build project

        cargo build
      3. Build & run project

        cargo run
      4. Check code

        cargo check
      5. Build for release

        cargo build --release
    2. Cargo.toml

      [package]
      name = "hello_cargo"
      version = "0.1.0"
      authors = ["Your Name <you@example.com>"]
      edition = "2018"
      
      [dependencies]