Rust

https://www.rust-lang.org/

Notes

Ownership

  • There are three rules to ownership in Rust:

    1. Each value has an owner

    2. There is only one owner of a value - other variables may borrow the value

    3. When the owner of a value goes out of scope, the value gets dropped immediately

  • In Rust, we use the term copy when only stack variables are copied; if there is heap data as well we use the term clone

  • When a value is dropped:

    1. the destructor, if available, is immediately run

    2. the heap portion is immediately freed

    3. the stack portion is immediately popped

References & Borrowing

  • A reference to a type is specified using the & (ampersand) notation

  • Rust introduces a concept called lifetimes, which can be summed up as the rule that references must always be valid, which means the compiler will not allow you to create a reference that outlives the value it is referencing, and you can never point to null

  • References are immutable by default, but can be changed to mutale using the &mut notation

  • At any given time, you can have either exactly one mutable reference or any numer of immutable references to a value

Resources

Articles

Books

Crates

  • cargo-chef - A cargo sub-command to build project dependencies for optimal Docker layer caching

  • criterion - Statistics-driven micro-benchmarking library

  • dioxus - Build fullstack web, desktop, and mobile apps with a single codebase

  • eyre - Flexible concrete Error Reporting type built on std::error::Error with customizable Reports

  • hyperfine - A command-line benchmarking tool

  • nom - A byte-oriented, zero-copy, parser combinators library

  • pest - The elegant parser

  • ratatui - A library that's all about cooking up terminal user interfaces

  • rayon - Simple work-stealing parallelism for Rust

  • regex - An implementation of regular expressions for Rust

Courses

GitHub repositories

IDEs

Libraries

  • CXX - safe interop between Rust and C++

Subreddits

Websites

YouTube channels

YouTube playlists

Last updated

Was this helpful?