Introducción a Rust (día 2)

adriandelgado

Diapositivas

adrianjdelgado.com/2024/rust-bridge-2
█▀▀▀▀▀█ ▀▀▀█▄▄▀ ▀▄▀▄▀ █▀▀▀▀▀█
█ ███ █  ▀▄█ █▀▀ ▄▀▄█ █ ███ █
█ ▀▀▀ █  ▄▀█▀▄▀ ▀▀█▀  █ ▀▀▀ █
▀▀▀▀▀▀▀ █▄▀ █▄█▄▀ ▀▄▀ ▀▀▀▀▀▀▀
██ ▀█▄▀ ▄▀▄ ▀ ▀█ █▄█  ▀▄▄ ▄▄▀
 ██ ▀▀▀█▄▀  ▀▀▀▀▀▄   █▄▄▀▄▀ ▄
█ ▀▄ █▀▄▀▀█ ▄ ▄█▄▄▄▀▀ ██▄▄▄▄█
█▀▄▄█▄▀▄▄█  ▄▀ ██  █▀   ▄ █ █
▄▄▀ ▀▀▀▄▄▄ █▀▀ █▀ █▄█   ▄▀▄▄
██▄ ▄█▀  ▀█▄▀█▄█▄  █▀▀▄███▄ ▀
▀▀▀▀ ▀▀ █  ▀█ █▄█▀▀ █▀▀▀██▀▀
█▀▀▀▀▀█   ▄▀█▀▄▀ ▄███ ▀ █▀ ▄▄
█ ███ █ ██▀█▄▄▄█  ▀▀██▀▀▀▀  ▄
█ ▀▀▀ █ ▄▀█  ▀▀██ █  █▄██▄█▀█
▀▀▀▀▀▀▀ ▀   ▀▀▀▀▀ ▀▀▀▀ ▀▀

Blazingly Fast

Herramientas

Rust Python Node Descripción
rustup rye nvm Version manager
cargo pip npm Dependency manager
clippy ruff eslint Linter
rustfmt black prettier Formatter

Rustup

  • rustup update
  • rustup install nightly|1.57
  • rustup show
  • rustup doc

Cargo

Comandos comúnes en Cargo

  • cargo new
  • cargo init
  • cargo add <crate>
  • cargo rm <crate>
  • cargo install <app>
  • cargo build [--release]
  • cargo run [--release]
  • cargo test
  • cargo bench

Clippy

  • cargo clippy
  • cargo clippy --fix

Rustfmt

  • cargo fmt
  • cargo fmt --check

Documentación

Estructuras de datos

  • Vec<T>
  • HashMap<K,V>
  • HashSet<V>

Conceptos nuevos

Stack & Heap

Slices

  • Vec<u8> vs &[u8]
  • String vs &str

Ownership & Borrowing

Option & Result

Iterators