Skip to content

Latest commit

 

History

History
51 lines (47 loc) · 2.07 KB

File metadata and controls

51 lines (47 loc) · 2.07 KB

Rust Fundamentals

Explore: Home Testing

Toolbox —

  • Rust Prelude
    • std::fmt[[fill]align][sign]['#']['0'][width]['.' precision]type
      • format!() ∙∙∙∙∙∙∙ print!() ∙∙∙∙∙∙∙ eprint!() ∙∙∙∙∙∙∙ write!()
      • {} fmt::Display ∙∙∙∙∙∙∙ {:?} {:#?} fmt::Debug
      • {:b} binary ∙∙∙∙∙∙∙ {:o} octal ∙∙∙∙∙∙∙ {:x} hex
      • fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {...}
    • Result<Ok(T), Err(_)>.expect()
    • Option<>

Cargo Cheatsheet —

  • cargo new <project_name> --lib
  • cargo doc --open
  • cargo [check | run | build --release]
  • cargo update

Cargo.toml —

[workspace]
resolver = "3"
members = ["projects/*"]
# ...............................
[dependencies]      # Uses SemVer; 0.4.2 shorthand for ^0.4.2, i.e. [0.4.2, 0.5.0)
utils = { path = "../utils" }
# ...............................
[lints.rust]
# dead_code = "allow"
# unused_variables = "allow"
# unused_imports = "allow"

Env Setup —

  • Windows Def. Install Path: C:\Users\<user> → ~\.rustup & ~\.cargo
  • Install | Rust-lang.org
  • Downloads | VS Code
  • In VSCode workspace, add .vscode/settings.json and list Cargo.toml's (for rust-analyzer extension)
    • {
          "rust-analyzer.linkedProjects": [
              ".\\hello-rust\\Cargo.toml",
              ".\\ratatui\\counter-app\\Cargo.toml",
              ".\\ratatui\\json-editor\\Cargo.toml"
          ]
      }