We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 244f2b9 commit ff1eb9cCopy full SHA for ff1eb9c
embedded-io-async/src/impls/slice_mut.rs
@@ -1,5 +1,7 @@
1
-use crate::Write;
2
use core::mem;
+use embedded_io::SliceWriteError;
3
+
4
+use crate::Write;
5
6
/// Write is implemented for `&mut [u8]` by copying into the slice, overwriting
7
/// its data.
@@ -14,6 +16,9 @@ impl Write for &mut [u8] {
14
16
#[inline]
15
17
async fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error> {
18
let amt = core::cmp::min(buf.len(), self.len());
19
+ if !buf.is_empty() && amt == 0 {
20
+ return Err(SliceWriteError::Full);
21
+ }
22
let (a, b) = mem::take(self).split_at_mut(amt);
23
a.copy_from_slice(&buf[..amt]);
24
*self = b;
0 commit comments