I'm confused with broadcast
channel, all work as expected when we use:
while let Ok(e) = rx.recv().await {
if let AppEvent::Ping(i) = e else { continue; }
println!("got ping: {i}");
tx.send(AppEvent::Pong(i)).unwrap();
}
but if we add patter match for enum like this in while loop:
while let Ok(AppEvent::Ping(i)) = rx.recv().await {
println!("got ping: {i}");
tx.send(AppEvent::Pong(i)).unwrap();
}
we receive only one Ping message and Pong on other site with same loop will not be received.
Just look at examples:
Working example:
Failing example:
I know broadcast receivers not receive previous messages, but they already subscribe on time we send Pong. What I miss in broadcast implementation?