diff --git a/examples/read_serialport.rs b/examples/read_serialport.rs index 98bd1da..1a416ae 100644 --- a/examples/read_serialport.rs +++ b/examples/read_serialport.rs @@ -76,7 +76,7 @@ pub fn main() -> io::Result<()> { // This should never happen as we only registered our // `UdpSocket` using the `UDP_SOCKET` token, but if it ever // does we'll log it. - error!("Got event for unexpected token: {:?}", event); + error!("Got event for unexpected token: {event:?}"); } } } diff --git a/src/lib.rs b/src/lib.rs index f8379ce..9fd5150 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,9 +64,7 @@ mod os_prelude { pub use winapi::um::fileapi::*; pub use winapi::um::handleapi::INVALID_HANDLE_VALUE; pub use winapi::um::winbase::{COMMTIMEOUTS, FILE_FLAG_OVERLAPPED}; - pub use winapi::um::winnt::{ - FILE_ATTRIBUTE_NORMAL, GENERIC_READ, GENERIC_WRITE, HANDLE, - }; + pub use winapi::um::winnt::{FILE_ATTRIBUTE_NORMAL, GENERIC_READ, GENERIC_WRITE, HANDLE}; } use os_prelude::*; @@ -668,7 +666,7 @@ mod io { } } - impl<'a> Read for &'a SerialStream { + impl Read for &SerialStream { fn read(&mut self, bytes: &mut [u8]) -> StdIoResult { uninterruptibly!(match unsafe { libc::read( @@ -683,7 +681,7 @@ mod io { } } - impl<'a> Write for &'a SerialStream { + impl Write for &SerialStream { fn write(&mut self, bytes: &[u8]) -> StdIoResult { uninterruptibly!(match unsafe { libc::write( diff --git a/tests/common.rs b/tests/common.rs index b0dd7b6..a3185ce 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -177,8 +177,8 @@ pub fn checked_read(port: &mut mio_serial::SerialStream, data: &mut [u8], expect pub struct Fixture { #[cfg(unix)] process: process::Child, - pub port_a: &'static str, - pub port_b: &'static str, + pub port_a: String, + pub port_b: String, } #[cfg(unix)] @@ -200,14 +200,11 @@ impl Fixture { pub fn new(port_a: &'static str, port_b: &'static str) -> Self { use std::sync::atomic::{AtomicUsize, Ordering}; static N: AtomicUsize = AtomicUsize::new(0); - LOGGING_INIT.call_once(|| env_logger::init()); + LOGGING_INIT.call_once(env_logger::init); let n = N.fetch_add(1, Ordering::Relaxed); - let port_a = format!("{}{}", port_a, n).leak(); - let port_b = format!("{}{}", port_b, n).leak(); - let args = [ - format!("PTY,link={}", port_a), - format!("PTY,link={}", port_b), - ]; + let port_a = format!("{port_a}{n}"); + let port_b = format!("{port_b}{n}"); + let args = [format!("PTY,link={port_a}"), format!("PTY,link={port_b}")]; log::trace!("starting process: socat {} {}", args[0], args[1]); let process = process::Command::new("socat") diff --git a/tests/test_serialstream.rs b/tests/test_serialstream.rs index 0f00af0..6b05336 100644 --- a/tests/test_serialstream.rs +++ b/tests/test_serialstream.rs @@ -10,7 +10,7 @@ const TOKEN2: Token = Token(1); fn test_builder_open_async() { let fixture = common::setup_virtual_serial_ports(); let baud_rate = 9600; - let builder = mio_serial::new(fixture.port_a, baud_rate); + let builder = mio_serial::new(&*fixture.port_a, baud_rate); let stream = builder .open_native_async() @@ -25,7 +25,7 @@ fn test_native_from_blocking() { let baud_rate = 9600; let fixture = common::setup_virtual_serial_ports(); - let port = fixture.port_a; + let port = &*fixture.port_a; let native_blocking = mio_serial::new(port, baud_rate) .open_native() .unwrap_or_else(|e| panic!("unable to open serial port {port}: {e}")); @@ -40,7 +40,7 @@ fn test_native_from_blocking() { fn test_stream_open() { let baud_rate = 9600; let fixture = common::setup_virtual_serial_ports(); - let port = fixture.port_a; + let port = &*fixture.port_a; let builder = mio_serial::new(port, baud_rate); let stream = mio_serial::SerialStream::open(&builder).expect("unable to open serial port"); @@ -54,7 +54,7 @@ fn test_stream_open() { fn test_port_enumeration() { let fixture = common::setup_virtual_serial_ports(); let ports = mio_serial::available_ports().expect("unable to enumerate serial ports"); - for name in [fixture.port_a, fixture.port_b] { + for name in [&*fixture.port_a, &*fixture.port_b] { ports .iter() .find(|&info| info.port_name == *name) @@ -73,7 +73,7 @@ fn test_read_write_pair() { let baud_rate = 38400; let fixture = common::setup_virtual_serial_ports(); - let (port_a, port_b) = (fixture.port_a, fixture.port_b); + let (port_a, port_b) = (&*fixture.port_a, &*fixture.port_b); let (mut poll, mut events) = common::init_with_poll(); let mut port_1 = mio_serial::new(port_a, baud_rate)