From 04b5e60e087f9869e6da01c6bf94af0f52556429 Mon Sep 17 00:00:00 2001 From: James Munns Date: Wed, 20 Dec 2023 14:17:24 +0100 Subject: [PATCH] A little more cleanup --- embassy-rp/src/uart/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index fcff032d..a11de101 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs @@ -251,13 +251,16 @@ impl<'d, T: Instance, M: Mode> UartRx<'d, T, M> { } pub fn blocking_read(&mut self, mut buffer: &mut [u8]) -> Result<(), Error> { - while buffer.len() > 0 { + while !buffer.is_empty() { let received = self.drain_fifo(buffer).map_err(|(_i, e)| e)?; buffer = &mut buffer[received..]; } Ok(()) } + /// Returns Ok(len) if no errors occurred. Returns Err((len, err)) if an error was + /// encountered. in both cases, `len` is the number of *good* bytes copied into + /// `buffer`. fn drain_fifo(&mut self, buffer: &mut [u8]) -> Result { let r = T::regs(); for (i, b) in buffer.iter_mut().enumerate() {