We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 35e4163 commit 11a64a1Copy full SHA for 11a64a1
library/std/src/io/readbuf.rs
@@ -306,8 +306,9 @@ impl<'a> BorrowedCursor<'a> {
306
307
impl<'a> Write for BorrowedCursor<'a> {
308
fn write(&mut self, buf: &[u8]) -> Result<usize> {
309
- self.append(buf);
310
- Ok(buf.len())
+ let amt = cmp::min(buf.len(), self.capacity());
+ self.append(&buf[..amt]);
311
+ Ok(amt)
312
}
313
314
#[inline]
0 commit comments