From 667abe6d1d78cc989fb57884643f4d2f5834ea52 Mon Sep 17 00:00:00 2001 From: chemicstry Date: Thu, 26 May 2022 14:11:15 +0300 Subject: [PATCH] Simplify example --- examples/stm32f4/src/bin/usart_buffered.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/stm32f4/src/bin/usart_buffered.rs b/examples/stm32f4/src/bin/usart_buffered.rs index c5fbbbe5..80b65f0d 100644 --- a/examples/stm32f4/src/bin/usart_buffered.rs +++ b/examples/stm32f4/src/bin/usart_buffered.rs @@ -26,13 +26,11 @@ async fn main(_spawner: Spawner, p: Peripherals) { unsafe { BufferedUart::new(&mut state, usart, irq, &mut tx_buf, &mut rx_buf) }; loop { - let n = { - let buf = buf_usart.fill_buf().await.unwrap(); - info!("Received: {}", buf); - buf.len() - }; + let buf = buf_usart.fill_buf().await.unwrap(); + info!("Received: {}", buf); // Read bytes have to be explicitly consumed, otherwise fill_buf() will return them again + let n = buf.len(); buf_usart.consume(n); } }