Skip to content

Commit

Permalink
Merge pull request #42 from rust-embedded-community/rs/bugfix
Browse files Browse the repository at this point in the history
Fixing an issue when writing empty buffers
  • Loading branch information
eldruin authored Dec 8, 2023
2 parents 6611dc0 + 096742c commit ca0b3cc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl<Bus: UsbBus> embedded_io::ReadReady for SerialPort<'_, Bus> {

impl<Bus: UsbBus> embedded_io::Write for SerialPort<'_, Bus> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
if buf.is_empty() {
return Ok(0);
}

loop {
match self.write(buf) {
// We are required by `embedded-io` to continue writing until at least one byte is
Expand Down

0 comments on commit ca0b3cc

Please sign in to comment.