When using a channel, let's say at a given moment we have the following messages in the queue for a given receiver:
abc
blah
abc
something
something
blah
something
Usually messages are processed like this:
let (sender, receiver) = mpsc::channel::<Msg>();
for msg in receiver {
// Process a message...
}
What is the easiest way to de-duplicate messages that have already piled up?
Using the above example, I'd like to only process 3 (not 7) messages:
abc
blah
something
Note: After a message abc
has been processed, it's fine to receive (and process) another message abc
again in the future. The goal is to only de-duplicate messages that have already piled-up in the queue.