If one attempts to write a zero sized buffer a panic occurs with 'tests::read_and_write_bytes' panicked at 'index out of bounds: the len is 0 but the index is 0'
The following patch and test corrects this issue by returning Ok(0) if the write is empty.
If one attempts to write a zero sized buffer a panic occurs with 'tests::read_and_write_bytes' panicked at 'index out of bounds: the len is 0 but the index is 0'
The following patch and test corrects this issue by returning Ok(0) if the write is empty.
diff --git a/src/lib.rs b/src/lib.rs index 8d4ba40..0baa6b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -503,7 +503,7 @@ impl io::Write for CircBuf { fn write(&mut self, buf: &[u8]) -> io::Result {
let avail = self.avail();
@@ -680,6 +680,7 @@ mod tests { fn read_and_write_bytes() { let mut c = CircBuf::with_capacity(8).unwrap();