diff options
| author | ache <ache@ache.one> | 2026-08-04 18:12:14 +0200 |
|---|---|---|
| committer | ache <ache@ache.one> | 2026-08-04 18:12:14 +0200 |
| commit | 5e51fb304d2fb9eb813f108c5d25e5f2c48b9798 (patch) | |
| tree | 58da0b23da667752e948b0f229657a78e0a3e45c /src/main.rs | |
| parent | Remove dead print_last_line (diff) | |
Remove dead code
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index e2c179e..5f4f1e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,16 +75,14 @@ async fn main() { states[id as usize] = State::Received { rtt: rtt, ttl }; } } - PingResult::NoPingErr { id: _, ref error } => { - // FEAT: It should fail if states is empty and print a informative characters on the line otherwise - eprintln!("Error: {}", error); - std::process::exit(2); + PingResult::NoPingErr { id } => { + states[id as usize] = State::SendError; } } } Err(TryRecvError::Disconnected) => { - // NOTE: Maybe we should quit, I don't know. - break; + eprintln!("Critical error, pinger thread killed"); + std::process::exit(2); } Err(TryRecvError::Empty) => { // No more ping to read @@ -95,7 +93,7 @@ async fn main() { // Put the cursor back up if !std::process::Command::new("tput").arg("rc").status().map(|s| s.success()).unwrap_or(false) { - println!("Process failed too"); + println!("Process failed too"); std::process::exit(1); } @@ -108,12 +106,12 @@ async fn main() { print_stats(&stats); } // Print stats of the last 30 pings - let firstIndex = if (states.len() as i32) - 30 > 0 { + let first_index = if (states.len() as i32) - 30 > 0 { states.len() - 30 } else { 0 }; - if let Some(stats) = compute_stats(&states[firstIndex..]) { + if let Some(stats) = compute_stats(&states[first_index..]) { print_stats(&stats); } } |