From e59a2d4dd720fa0584bbb68e222739109593cc77 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Fri, 22 May 2015 17:12:39 -0700 Subject: [PATCH] Don't panic in log generator --- examples/logs.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/logs.rs b/examples/logs.rs index 6d4efd1..871804a 100644 --- a/examples/logs.rs +++ b/examples/logs.rs @@ -36,8 +36,10 @@ fn generate_logs(tx: mpsc::Sender) { loop { let line = format!("Interesting log line {}", i); i += 1; + // The send will fail when the other side is dropped. + // (When the application ends). match tx.send(line) { - Err(_) => panic!("Uh?..."), + Err(_) => return, Ok(_) => (), } thread::sleep_ms(30);