Closed wyatt-herkamp closed 2 years ago
I think the lifetime is still desirable because even though it's circumstantially not needed due to the design of the crate, there's still a logical relationship here.
In your case, you could just clone the receiver (cloning senders and receivers is fairly cheap) like so:
fn handle_updates(&mut self) {
let r = self.server_update_receiver.clone();
for update in r.drain() {
self.handle_update(update);
}
}
Ok
So I have this function in my structure that is going to handle all updates received in the channel. Because the fact Drain has the life time of a immutable borrow for self. I now have an immutable borrow on self. Meaning I can't leave this function
I noticed the docs said this and I was wondering if you were considering removing the life time constraint. Anytime soon because it would make my code a bit easier if I don't have all of the update handling done within this one method.