Rust's iterators are more interesting than they look

Sdílet
Vložit
  • čas přidán 8. 06. 2024
  • Manually creating for loops is error prone and tedious. Learn about how Rust provides tools that make many common errors impossible to create, without incurring runtime costs.
    🦀 Rust resources:
    - Tim's tutorial videos timclicks.dev
    - Rust Documentation: doc.rust-lang.org/book/
    - Rust Playground: play.rust-lang.org/
    - Rust in Action (Tim's book!) mng.bz/4MlD
    - How to Learn Rust (online course!) learning.accelerant.dev/how-t...
    👋 Connect with Tim:
    - Twitter: / timclicks
    - GitHub: github.com/timClicks
    - Mastodon: mastodon.nz/@timClicks
    - DEV: dev.to/timclicks/
    - Patreon (extra learning materials) / timclicks
    🔔 Subscribe to the channel and click the bell icon to stay updated with the latest videos and live streams from timClicks: czcams.com/users/timClicks?sub...
    👍 Like this video if you found it helpful, and share it with your friends who are also interested in Rust programming.
  • Věda a technologie

Komentáře • 29

  • @darklajid
    @darklajid Před 10 měsíci +20

    Wait. Am I losing my mind or are you saying "integer" instead of "iterator" the first two times in the video/in the first 10 seconds?

    • @JamesRouzier
      @JamesRouzier Před 10 měsíci +1

      He did say integer

    • @timClicks
      @timClicks  Před 10 měsíci +5

      Probably. My brain is a bit weird sometimes 😅

    • @JamesRouzier
      @JamesRouzier Před 10 měsíci +8

      @@timClicks no problem it is a good way to increase engagement.
      Sprinkle little mistakes in your videos.
      Then people will point then out in the comments.

  • @philippschulz7404
    @philippschulz7404 Před 3 měsíci

    Hey Tim!
    Thanks for this great educational resource. 🤓
    I'm currently learning Rust and this video perfectly closes the gap between the knowledge I've gained from the Rust book and the questions I've personally had about iterators. One thing I find difficult as a learner is understanding how to figure out which iterator methods can be chained and which cannot.

  • @michaelmueller9635
    @michaelmueller9635 Před 10 měsíci +3

    When I was going into Rust, it first really confused me, how obsessed Rust with iterators is. It's almost impossible to loop collections by indices and do some weird stuff by indices hopping. If you are coming from C++, this should be easy.
    But one big advantage in Rust: Because the iterators are so standardized and all over the place, you can swap the underlying data structure really easily (as long as the iterator-trait is implemented).
    So you don't have to mind for the perfect data structure at the beginning by casting the data structure into the design of your program. You can swap the data structure later on (by benchmark testing or if the requirements for the project are changing).

    • @MarcusBrito
      @MarcusBrito Před 10 měsíci +1

      Iterator compose _very_ nicely and through composition you can perform the stuff you mentioned here. For example, `Iterator::enumerate()` transforms an iterator's output into a tuple of (index, element) - probably what you need to loop a collection by index, and `Iterator::step_by()` gives you index hopping. If the standard iterator trait is missing a transformation you need, chances are, you'll find it in the `itertools` crate.

  • @pbnjdev
    @pbnjdev Před 10 měsíci +6

    As usual, Tim, thank you for the explainer and the great content.
    I had a question and a correction:
    1. At 13:37 - any reason why `Option` should not be re-written more concisely as `Option`? The compiler doesn't seem to mind/complain.
    2. At 13:51 - there is an error - `if some.remaining_iterations` , but it should be `if self.remaining_iterations`

    • @timClicks
      @timClicks  Před 10 měsíci +7

      Thanks for those comments Peter. I think that your intuition is correct. You may have noticed that I hesitated at 13:37 because I wondered that myself. Either is fine.
      Thank you for notifying me of the typo at 13:51 - this proves that I shouldn't use slide show software as an IDE.

  • @pixelsandpointers
    @pixelsandpointers Před 10 měsíci +3

    I am a fan of the slides' design. Had to say that, content as always very nice :)

  • @pramodjingade6581
    @pramodjingade6581 Před 9 měsíci

    @timClicks: 💡Thank you for this excellent video..may I ask which tool you use for the presentation ? Very well presented !!

    • @timClicks
      @timClicks  Před 9 měsíci +1

      Google Slides and too much time tweaking animations :)

    • @pramodjingade6581
      @pramodjingade6581 Před 9 měsíci

      @@timClicks thank you for replying, big fan 🙂

  • @jesussantander6511
    @jesussantander6511 Před 10 měsíci +1

    Amazing content Tim.

    • @timClicks
      @timClicks  Před 10 měsíci

      Thank you! Please share with anyone who might be interested :)

  • @ivanchien4248
    @ivanchien4248 Před 10 měsíci

    A nice video for Rust learners. btw can you tell me the code font you used in the slide?

    • @timClicks
      @timClicks  Před 10 měsíci

      It's called Martian Mono github.com/evilmartians/mono

    • @ivanchien4248
      @ivanchien4248 Před 10 měsíci

      @@timClicks thx!

  • @jackkendall6420
    @jackkendall6420 Před 10 měsíci +3

    As a bit of constructive criticism, I would practice the voiceover once or twice before recording the final take, and read from a script if you aren't already. The ums and ahs distracted from the really quite high-quality slides.

    • @timClicks
      @timClicks  Před 10 měsíci +1

      Thanks very much for taking the time to provide this comment. It's been on my mind for a while. The narration is currently unscripted, which lends itself to lots of distracting fillers. I'm aiming to steadily improve my delivery for another increase in quality over the next few weeks.

    • @jackkendall6420
      @jackkendall6420 Před 10 měsíci

      @@timClicks That's excellent to hear. I've subscribed to support the effort you're obviously putting into this channel.

    • @timClicks
      @timClicks  Před 10 měsíci

      @@jackkendall6420 Thanks Jack. Am curious to hear your opinion on this one czcams.com/video/nCNjzoKHtHk/video.html

    • @peter9477
      @peter9477 Před 10 měsíci

      Or just invest more time in editing. It's not critical to do it in one shot, and many of the best videos from others have many cuts. But I'm subscribed too, to support the passion. :-)

    • @timClicks
      @timClicks  Před 10 měsíci

      Thank you! More recent videos have better editing

  • @thegeniusfool
    @thegeniusfool Před měsícem

    It’s sad that this is so foreign and absurd to most so called senior developers.

    • @timClicks
      @timClicks  Před měsícem

      Everyone's at their own stage in the journey.