From c82432863462bc893b5e1cc2e56fe1bfa9f4ba23 Mon Sep 17 00:00:00 2001 From: "jakob.stendahl" Date: Mon, 17 Jun 2024 09:52:53 +0200 Subject: Don't panic on invalid lines when operating in filtering mode --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e97b085..3a0a72c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,9 +76,15 @@ fn filter(opts: OptsBuilder) { i += 1.0; let line = line.expect("Could not read..."); - let y = f64::from_str(line.as_str()).expect("TG7 invalid number"); - y_values.push(y); - x_values.push(i); + let y = f64::from_str(line.as_str()); + if let Err(_) = y { + print!("Could not parse line as f64."); + continue; + } + if let Ok(y) = y { + y_values.push(y); + x_values.push(i); + } #[cfg(feature = "ansi")] print!("\x1B[2J\x1B[H"); -- cgit v1.2.3