Mpsc::channel Receiver peek?

  1. I know about iter and try_iter.

  2. Since there is only one receiver, is there a way to

  • get a Option to the next item up

  • do some processing of the item

  • depending on the results of processing, either take the elem (consuming it) or do nothing (leaving the item still first in the Receiver channel)

1 Like

You can add peek to any iterator with .peekable(), so it should work for receiver's iterator too.

2 Likes

peekable() is precisely what I needed. Thanks!

1 Like