Update main.rs

fix "While let Conditional Loops" Code not match
This commit is contained in:
吴俊城 2024-11-17 19:58:14 +08:00 committed by GitHub
parent d240e1e2ab
commit 46e3cf0793
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,14 +1,13 @@
fn main() { fn main() {
// ANCHOR: here // ANCHOR: here
let (tx, rx) = std::sync::mpsc::channel(); let mut stack = Vec::new();
std::thread::spawn(move || {
for val in [1, 2, 3] {
tx.send(val).unwrap();
}
});
while let Ok(value) = rx.recv() { stack.push(1);
println!("{value}"); stack.push(2);
stack.push(3);
while let Some(top) = stack.pop() {
println!("{top}");
} }
// ANCHOR_END: here // ANCHOR_END: here
} }