while let Ok(notification) = self.event_loop.poll().await {
if let Event::Incoming(Incoming::Publish(publish)) = notification {
for (regex, handler) in &self.handlers {
if let Some(matches) = regex.find(&publish.topic) {
let matches = publish.topic[matches.range()].to_string();
match handler(self.state.clone(), &self, &publish, matches) {
Ok(fut) => {
if let Err(e) = fut.await {
println!("{:?}", &e);
}
}
Err(e) => println!("{:?}", &e),
}
}
}
}
}
}
Почему тогда этот метод не ломался? pub async fn listen(mut self) { while let Ok(notification) = self.event_loop.poll().await { // &mut self.event_loop if let Event::Incoming(Incoming::Publish(publish)) = notification { for (regex, handler) in &self.handlers { if let Some(matches) = regex.find(&publish.topic) { let matches = publish.topic[matches.range()].to_string(); match handler(self.state.clone(), &self, &publish, matches) { // &self Ok(fut) => { if let Err(e) = fut.await { println!("{:?}", &e); } } Err(e) => println!("{:?}", &e), } } } } } }
Обсуждают сегодня