Skip to content

Instantly share code, notes, and snippets.

@aagontuk
Last active March 2, 2024 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aagontuk/e681b90c7c16888c186ad2a95cdd23c7 to your computer and use it in GitHub Desktop.
Save aagontuk/e681b90c7c16888c186ad2a95cdd23c7 to your computer and use it in GitHub Desktop.
Rust resources

References

Notes (These could be totally wrong!)

  • Box<T> to allocate from heap.
  • Rc<T> to share variable among multiple owners without lifetime parametes in a single threaded program. It only allows immutable access to data. Value needs to wrapped in RefCell<T> if mutability is desired.
  • T.clone() does a deep copy. Avoid deep copy with Rc::clone(&T).
  • RefCell<T> is used to mutate the value inside an immutable value. This is called interior mutability pattern. RefCell<T> inforces same borrow checking rules in runtime.
  • Arc<T> to share T among multiple threads.

Q&A

Env Setup

General Setup

rustup component add rust-analyzer
rustup component add clippy

VIM setup rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment