From 534c53c901345f8af517b8991a4bcd99d290c11c Mon Sep 17 00:00:00 2001 From: Andres Vahter Date: Fri, 19 Jan 2024 19:58:00 +0200 Subject: [PATCH] stm32 uart: remove unwrap unwraps take more space because of panics --- embassy-stm32/src/usart/buffered.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 52740c13e..abc766bc7 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs @@ -47,8 +47,10 @@ impl interrupt::typelevel::Handler for Interrupt let mut rx_writer = state.rx_buf.writer(); let buf = rx_writer.push_slice(); if !buf.is_empty() { - buf[0] = dr.unwrap(); - rx_writer.push_done(1); + if let Some(byte) = dr { + buf[0] = byte; + rx_writer.push_done(1); + } } else { // FIXME: Should we disable any further RX interrupts when the buffer becomes full. }