I have a collection containing `std::sync::mpsc::Receiver<Message>` and want to sort them into other collections depending on the message in it.

I'm iterating into the receivers, testing if they received a message, if so I test the message nature, and depending on it, I move the receiver to another collection:

```
for receiver in receivers.iter() {
    if let Ok(msg) = receiver.try_recv() {
        match msg {
            Message::Foo => {
                // TODO remove receiver from receivers
                foos.push(receiver);
            },
            Message::Bar => {
                // TODO remove receiver from receivers
                bars.push(receiver);
            },
        }
    }
}

```

I do not know how to remove `receiver` from the `receivers` collection. Since I'm borrowing it as immutable while iterating over it, I can not modify it without encountering compilation error

I have the feeling that I'm not using the right Rust tools to complete this very basic algorithm.

[![illustration](https://i.stack.imgur.com/HSaOG.png)](https://i.stack.imgur.com/HSaOG.png)

To illustrate my problem, imagine that I'm sorting the colored balls from collection A to collections B and C, but I can not clone the balls and I can only see the color of a ball when taking it, which destroys the color when I take the next ball.

The solution of labeling the balls from number 0 to number 6, writing down its color aside to its index and then taking the balls to put them in the good collection is inconvenient.