Mpsc::channel Receiver peek?

#1
  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)

0 Likes

#2

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

1 Like

#3

peekable() is precisely what I needed. Thanks!

1 Like