Episode #2

Snakes and Gears

Let's talk about Python and Rust. I used to do a lot more Python than I do now, but I still love it for its beauty.

One of the first things I was missing in Rust when coming from Python were List Comprehensions. It took me a while to figure out, that the Rust way - using iter(), filter(), and map() - actually is a better fit for the language. I want to show you how to port Rust list comprehensions to Rust.

▶ Run and edit code on Gitpod

Keywords

iterators, map, filter, Entry API, List comprehensions

Things I mentioned during the show

  • Reading files using the Rust Cookbook.
  • DevDocs is a nice Rust documentation viewer. Also supports a ton of other languages and works offline.

Things I should have mentioned (but forgot)

  • Iteration patterns for Result & Option
  • Experimenting with Python is much cooler with Jupyter (or IPython) notebooks. I've added an example to the code section.
  • If you really need list comprehensions, you could use cute, which is a set of macros that make this syntax possible.

Meta

Resources and licenses

Support!

Preparing, recording, and editing an episode takes a substantial amount of time (around 30 hours total). I do all of this next to my fulltime dayjob. If you want to show your appreciation and help me keep the content free for everybody to enjoy, please consider supporting me on Patreon - no matter the amount. ❤️