From 2d109e272a42473b747b45d77e743d0eac1a3d77 Mon Sep 17 00:00:00 2001 From: Christian Meusel Date: Thu, 28 Mar 2024 17:35:36 +0100 Subject: [PATCH] Fix some issues pointed out by Clippy in examples and tests In case of writing data, the code looks like it expects all data to be written. And in case of reading data it expects some data to be read. Let's make this explicit. --- examples/clear_input_buffer.rs | 2 +- examples/clear_output_buffer.rs | 4 ++-- tests/test_tty.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/clear_input_buffer.rs b/examples/clear_input_buffer.rs index 112a88c9..48491e43 100644 --- a/examples/clear_input_buffer.rs +++ b/examples/clear_input_buffer.rs @@ -125,7 +125,7 @@ fn input_service() -> mpsc::Receiver<()> { drop(tx); // EOF, drop the channel and stop the thread break; } - Ok(_) => tx.send(()).unwrap(), // Signal main to clear the buffer + Ok(_bytes_read) => tx.send(()).unwrap(), // Signal main to clear the buffer Err(e) => panic_any(e), } } diff --git a/examples/clear_output_buffer.rs b/examples/clear_output_buffer.rs index 631e3967..d873860e 100644 --- a/examples/clear_output_buffer.rs +++ b/examples/clear_output_buffer.rs @@ -85,7 +85,7 @@ fn run(port_name: &str, baud_rate: &str, block_size: usize) -> Result<(), Box (), Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (), Err(e) => panic!("Error while writing data to the port: {}", e), @@ -125,7 +125,7 @@ fn input_service() -> mpsc::Receiver<()> { drop(tx); // EOF, drop the channel and stop the thread break; } - Ok(_) => tx.send(()).unwrap(), // Signal main to clear the buffer + Ok(_bytes_read) => tx.send(()).unwrap(), // Signal main to clear the buffer Err(e) => panic_any(e), } } diff --git a/tests/test_tty.rs b/tests/test_tty.rs index 02aa061f..46f4ae72 100644 --- a/tests/test_tty.rs +++ b/tests/test_tty.rs @@ -98,7 +98,7 @@ fn test_osx_pty_pair() { let (output_sink, output_stream) = std::sync::mpsc::sync_channel(1); let name = slave.name().unwrap(); - master.write("12".as_bytes()).expect(""); + master.write_all("12".as_bytes()).expect(""); let reader_thread = std::thread::spawn(move || { let mut port = TTYPort::open(&serialport::new(&name, 0)).expect("unable to open");