Skip to content

Commit 6ff225f

Browse files
committed
fix warnings
1 parent cb28b14 commit 6ff225f

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

serial-core/src/lib.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,10 @@ pub trait SerialPort: io::Read + io::Write {
492492
/// })
493493
/// }
494494
/// ```
495-
fn reconfigure(&mut self, setup: &Fn(&mut SerialPortSettings) -> ::Result<()>) -> ::Result<()>;
495+
fn reconfigure(
496+
&mut self,
497+
setup: &dyn Fn(&mut dyn SerialPortSettings) -> ::Result<()>,
498+
) -> ::Result<()>;
496499

497500
/// Sets the state of the RTS (Request To Send) control signal.
498501
///
@@ -585,9 +588,9 @@ impl<T> SerialPort for T
585588
}
586589

587590
fn configure(&mut self, settings: &PortSettings) -> ::Result<()> {
588-
let mut device_settings = try!(T::read_settings(self));
591+
let mut device_settings = T::read_settings(self)?;
589592

590-
try!(device_settings.set_baud_rate(settings.baud_rate));
593+
device_settings.set_baud_rate(settings.baud_rate)?;
591594
device_settings.set_char_size(settings.char_size);
592595
device_settings.set_parity(settings.parity);
593596
device_settings.set_stop_bits(settings.stop_bits);
@@ -596,9 +599,12 @@ impl<T> SerialPort for T
596599
T::write_settings(self, &device_settings)
597600
}
598601

599-
fn reconfigure(&mut self, setup: &Fn(&mut SerialPortSettings) -> ::Result<()>) -> ::Result<()> {
600-
let mut device_settings = try!(T::read_settings(self));
601-
try!(setup(&mut device_settings));
602+
fn reconfigure(
603+
&mut self,
604+
setup: &dyn Fn(&mut dyn SerialPortSettings) -> ::Result<()>,
605+
) -> ::Result<()> {
606+
let mut device_settings = T::read_settings(self)?;
607+
setup(&mut device_settings)?;
602608
T::write_settings(self, &device_settings)
603609
}
604610

serial-unix/src/error.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use core;
22

3-
use std::error::Error;
43
use std::ffi::CStr;
54
use std::io;
65
use std::str;
@@ -30,7 +29,7 @@ pub fn from_io_error(io_error: io::Error) -> core::Error {
3029
match io_error.raw_os_error() {
3130
Some(errno) => from_raw_os_error(errno),
3231
None => {
33-
let description = io_error.description().to_string();
32+
let description = io_error.to_string();
3433

3534
core::Error::new(core::ErrorKind::Io(io_error.kind()), description)
3635
}

serial-unix/src/tty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ impl TTYPort {
7979
}
8080

8181
// apply initial settings
82-
let settings = try!(port.read_settings());
83-
try!(port.write_settings(&settings));
82+
let settings = port.read_settings()?;
83+
port.write_settings(&settings)?;
8484

8585
Ok(port)
8686
}
@@ -126,7 +126,7 @@ impl AsRawFd for TTYPort {
126126

127127
impl io::Read for TTYPort {
128128
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
129-
try!(super::poll::wait_read_fd(self.fd, self.timeout));
129+
super::poll::wait_read_fd(self.fd, self.timeout)?;
130130

131131
let len = unsafe {
132132
libc::read(self.fd, buf.as_ptr() as *mut c_void, buf.len() as size_t)
@@ -143,7 +143,7 @@ impl io::Read for TTYPort {
143143

144144
impl io::Write for TTYPort {
145145
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
146-
try!(super::poll::wait_write_fd(self.fd, self.timeout));
146+
super::poll::wait_write_fd(self.fd, self.timeout)?;
147147

148148
let len = unsafe {
149149
libc::write(self.fd, buf.as_ptr() as *mut c_void, buf.len() as size_t)

serial-windows/src/com.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl COMPort {
5858
timeout: timeout,
5959
};
6060

61-
try!(port.set_timeout(timeout));
61+
port.set_timeout(timeout)?;
6262
Ok(port)
6363
}
6464
else {

0 commit comments

Comments
 (0)