@@ -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
0 commit comments