IV Notes
  • Introduction
  • Programming
    • Cheatsheet: Option (in Rust) vs Maybe (in Haskell)
    • printf() and floating point numbers
    • More advanced aspects of pattern matching in Rust
    • time_it: a Case Study in Rust Macros
    • Rust Closures: Returning `impl Fn` for `move` closures
    • Allocation API, allocators and virtual memory
    • Checking status of Rust features
  • Game Development
    • 🐍Snake: an exercise in game development
  • Miscellaneous
    • Technical newsletters
  • Roguelikes
  • Travel
    • Torres del Paine
    • Tents
  • Bits and Pieces
    • Rust
    • Command line
    • GMail backup
    • Git
    • CSS
  • Audio/video encoding tips
    • Resizing video with ffmpeg
    • Mono to stereo
Powered by GitBook
On this page
  • Useful commands
  • Closures
  • Common/standard traits, conversion
  • Lifetimes, NLL
  • Error handling
  • Profiling on Mac
  • Misc
  1. Bits and Pieces

Rust

Bits and pieces of Rust

PreviousTentsNextCommand line

Last updated 4 years ago

Useful commands

  • To override default toolchain for a particular project: rustup override set nightly. The directory is stored in ~/.rustup/settings.toml (in overrides section) separately from the project itself.

  • To print all package dependencies as a nice tree in the command line, we can use cargo tree - more details (works starting from Rust 1.44)

Closures

  • A by Steven Donovan about closures in Rust. It makes the connection between closures and structs, explains why move |...| is sometimes needed and why we have to add lifetimes annotations like where F: Fn(i32) -> i32 + 'a>

  • All the nitty-gritty details are available in the Rust language reference (sections and ).

Common/standard traits, conversion

  • by Lloqiq (2015)

  • by Steve Donovan (2018)

  • part from "Designing elegant APIs in Rust" by Pascal Hertleif (a very insightful post!) (2016)

  • section in "Rust by Example"

  • by Ricardo Martins (2016)

  • Rust reference:

Lifetimes, NLL

  • about Non-Lexical Lifetimes: why and when they are needed, design

  • and the following sections in Rustonomicon

  • by Maksym Zavershynskyi

Error handling

Profiling on Mac

Misc

- many error handling packages reviewed and compared

by Andrew Gallant (burntsushi)

on Reddit

sample

by Carol Nichols, a simple easy to follow reference

by Jon Gjengset for producing flame-graphs from process samples. Rust port of tools. Its README.md on GitHub has lots of useful information. Btw, there is a 5 hours of how this tool was actually coded live!

- an interesting explanation about traits and other items known to the Rust compiler and marked with #[lang] annotation. I really enjoyed this article, but for some reason it was quite hard to google to find it again (perhaps because I googled "traits" and "lang" is not a very googleable term).

here
good post
"Closure expressions"
"Closure types"
"Rust's Built-in Traits, the When, How & Why"
"The Common Rust Traits"
"Use conversion traits"
"Conversion"
"Convenient and idiomatic conversions in Rust"
"Special types and traits"
RFC-2094
"Lifetimes"
"Understanding Rust Lifetimes"
Common Rust lifetimes misconceptions
Error handling survey - 13 Nov 2019
Structuring and handling errors in 2020
Error handling in Rust
The state of error handling in Rust 2018 edition
Notice: failure is deprecated
Profiling with
"Rust profiling with DTrace and FlameGraph on MacOs"
Inferno
flame-graph
video stream
"Rust Tidbits: What is a Lang Item?"