Skip to content

Commit 3215d0d

Browse files
committed
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.
1 parent 1d3e9ce commit 3215d0d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

examples/clear_input_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn input_service() -> mpsc::Receiver<()> {
125125
drop(tx); // EOF, drop the channel and stop the thread
126126
break;
127127
}
128-
Ok(_) => tx.send(()).unwrap(), // Signal main to clear the buffer
128+
Ok(_bytes_read) => tx.send(()).unwrap(), // Signal main to clear the buffer
129129
Err(e) => panic_any(e),
130130
}
131131
}

examples/clear_output_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn run(port_name: &str, baud_rate: &str, block_size: usize) -> Result<(), Box<dy
8585
// This loop writes the block repeatedly, as fast as possible, to try to saturate the
8686
// output buffer. If you don't see much data queued to send, try changing the block size.
8787
loop {
88-
match port.write(&block) {
88+
match port.write_all(&block) {
8989
Ok(_) => (),
9090
Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (),
9191
Err(e) => panic!("Error while writing data to the port: {}", e),
@@ -125,7 +125,7 @@ fn input_service() -> mpsc::Receiver<()> {
125125
drop(tx); // EOF, drop the channel and stop the thread
126126
break;
127127
}
128-
Ok(_) => tx.send(()).unwrap(), // Signal main to clear the buffer
128+
Ok(_bytes_read) => tx.send(()).unwrap(), // Signal main to clear the buffer
129129
Err(e) => panic_any(e),
130130
}
131131
}

tests/test_tty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn test_osx_pty_pair() {
9898
let (output_sink, output_stream) = std::sync::mpsc::sync_channel(1);
9999
let name = slave.name().unwrap();
100100

101-
master.write("12".as_bytes()).expect("");
101+
master.write_all("12".as_bytes()).expect("");
102102

103103
let reader_thread = std::thread::spawn(move || {
104104
let mut port = TTYPort::open(&serialport::new(&name, 0)).expect("unable to open");

0 commit comments

Comments
 (0)