janriemer,

Oh wow, did you know that in you can use Option as an iterator such that your types align, when you want to return a chain of iterators from a function, but also have an else case where the iterator is empty!?

I know, this was a mouthful.😳

Let's look at a playground that shows this:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=129eb419d767b71447b408e456773555

This trick is right from the docs on option:

https://doc.rust-lang.org/stable/std/option/#iterating-over-option

What a cunning trick!🤓

Rust, I ❤️ you!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • rust
  • DreamBathrooms
  • magazineikmin
  • everett
  • InstantRegret
  • rosin
  • Youngstown
  • slotface
  • love
  • khanakhh
  • kavyap
  • tacticalgear
  • GTA5RPClips
  • thenastyranch
  • modclub
  • megavids
  • mdbf
  • normalnudes
  • Durango
  • ethstaker
  • osvaldo12
  • cubers
  • ngwrru68w68
  • tester
  • anitta
  • cisconetworking
  • Leos
  • provamag3
  • JUstTest
  • All magazines