From 020c9d9a3de9057ee2b79be40e00e24bcec4101d Mon Sep 17 00:00:00 2001 From: Nic0w Date: Wed, 5 May 2021 08:06:47 +0200 Subject: [PATCH] cargo clippy & fmt --- rp2040-hal/src/uart.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rp2040-hal/src/uart.rs b/rp2040-hal/src/uart.rs index 0de5dc5..ee44a04 100644 --- a/rp2040-hal/src/uart.rs +++ b/rp2040-hal/src/uart.rs @@ -267,7 +267,7 @@ impl UARTPeripheral { bytes_written += 1; } - return Ok(&data[bytes_written..]); + Ok(&data[bytes_written..]) } /// Reads bytes from the UART. @@ -363,7 +363,8 @@ fn calculate_baudrate_dividers( ) -> Result<(u16, u16), Error> { // See Chapter 4, Section 2 ยง7.1 from the datasheet for an explanation of how baudrate is // calculated - let baudrate_div = frequency.integer() + let baudrate_div = frequency + .integer() .checked_mul(8) .and_then(|r| r.checked_div(*wanted_baudrate.integer())) .ok_or(Error::BadArgument)?; @@ -452,8 +453,8 @@ impl Read for UARTPeripheral { match self.read_raw(byte) { Ok(_) => Ok(byte[0]), Err(e) => match e { - Other(inner) => return Err(Other(inner.err_type)), - WouldBlock => return Err(WouldBlock), + Other(inner) => Err(Other(inner.err_type)), + WouldBlock => Err(WouldBlock), }, } } @@ -463,7 +464,7 @@ impl Write for UARTPeripheral { type Error = Infallible; fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { - if let Err(_) = self.write_raw(&[word]) { + if self.write_raw(&[word]).is_err() { Err(WouldBlock) } else { Ok(())