Use while let to loop over Option or Result values until they stop matching a specific pattern.
Use while let to loop over an expression that returns an Option or Result, executing the block only when the value matches a specific pattern.
while let Some(value) = rx.recv().await {
println!("received '{value}'");
}
This loop continues as long as rx.recv().await returns Some(value), automatically stopping when it returns None.
Think of while let as a loop that keeps running only while a specific condition is true, like a vending machine that keeps dispensing items as long as you have coins. It stops automatically the moment the condition fails, such as when the machine runs out of stock. This saves you from writing extra code to check if the loop should stop.