cargo clippy & fmt

This commit is contained in:
Nic0w 2021-05-05 08:06:47 +02:00
parent c35358f475
commit 020c9d9a3d

View file

@ -267,7 +267,7 @@ impl<D: UARTDevice> UARTPeripheral<Enabled, D> {
bytes_written += 1; bytes_written += 1;
} }
return Ok(&data[bytes_written..]); Ok(&data[bytes_written..])
} }
/// Reads bytes from the UART. /// Reads bytes from the UART.
@ -363,7 +363,8 @@ fn calculate_baudrate_dividers(
) -> Result<(u16, u16), Error> { ) -> Result<(u16, u16), Error> {
// See Chapter 4, Section 2 §7.1 from the datasheet for an explanation of how baudrate is // See Chapter 4, Section 2 §7.1 from the datasheet for an explanation of how baudrate is
// calculated // calculated
let baudrate_div = frequency.integer() let baudrate_div = frequency
.integer()
.checked_mul(8) .checked_mul(8)
.and_then(|r| r.checked_div(*wanted_baudrate.integer())) .and_then(|r| r.checked_div(*wanted_baudrate.integer()))
.ok_or(Error::BadArgument)?; .ok_or(Error::BadArgument)?;
@ -452,8 +453,8 @@ impl<D: UARTDevice> Read<u8> for UARTPeripheral<Enabled, D> {
match self.read_raw(byte) { match self.read_raw(byte) {
Ok(_) => Ok(byte[0]), Ok(_) => Ok(byte[0]),
Err(e) => match e { Err(e) => match e {
Other(inner) => return Err(Other(inner.err_type)), Other(inner) => Err(Other(inner.err_type)),
WouldBlock => return Err(WouldBlock), WouldBlock => Err(WouldBlock),
}, },
} }
} }
@ -463,7 +464,7 @@ impl<D: UARTDevice> Write<u8> for UARTPeripheral<Enabled, D> {
type Error = Infallible; type Error = Infallible;
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { 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) Err(WouldBlock)
} else { } else {
Ok(()) Ok(())