@@ -29,8 +29,7 @@ fn get_ports_guids() -> Result<Vec<GUID>> {
2929
3030 // Size vector to hold 1 result (which is the most common result).
3131 let mut num_guids: DWORD = 0 ;
32- let mut guids: Vec < GUID > = Vec :: new ( ) ;
33- guids. push ( GUID_NULL ) ; // Placeholder for first result
32+ let mut guids = vec ! [ GUID_NULL ] ; // Placeholder for first result
3433
3534 // Find out how many GUIDs are associated with "Ports". Initially we assume
3635 // that there is only 1. num_guids will tell us how many there actually are.
@@ -229,8 +228,8 @@ impl PortDevice {
229228 if let Ok ( vid) = u16:: from_str_radix ( & caps[ 1 ] , 16 ) {
230229 if let Ok ( pid) = u16:: from_str_radix ( & caps[ 2 ] , 16 ) {
231230 return SerialPortType :: UsbPort ( UsbPortInfo {
232- vid : vid ,
233- pid : pid ,
231+ vid,
232+ pid,
234233 serial_number : caps. get ( 4 ) . map ( |m| m. as_str ( ) . to_string ( ) ) ,
235234 manufacturer : self . property ( SPDRP_MFG ) ,
236235 product : self . property ( SPDRP_FRIENDLYNAME ) ,
@@ -257,10 +256,8 @@ impl PortDevice {
257256 ptr:: null_mut ( ) ,
258257 )
259258 } ;
260- if res == FALSE {
261- if unsafe { GetLastError ( ) } != ERROR_INSUFFICIENT_BUFFER {
262- return None ;
263- }
259+ if res == FALSE && unsafe { GetLastError ( ) } != ERROR_INSUFFICIENT_BUFFER {
260+ return None ;
264261 }
265262 let end_of_buffer = result_buf. len ( ) - 1 ;
266263 result_buf[ end_of_buffer] = 0 ;
@@ -292,7 +289,7 @@ pub fn available_ports() -> Result<Vec<SerialPortInfo>> {
292289 }
293290
294291 ports. push ( SerialPortInfo {
295- port_name : port_name ,
292+ port_name,
296293 port_type : port_device. port_type ( ) ,
297294 } ) ;
298295 }
0 commit comments