We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Read::read_buf
1 parent 89e0576 commit d7dac91Copy full SHA for d7dac91
library/std/src/io/mod.rs
@@ -549,6 +549,7 @@ where
549
#[stable(feature = "rust1", since = "1.0.0")]
550
#[doc(notable_trait)]
551
#[cfg_attr(not(test), rustc_diagnostic_item = "IoRead")]
552
+#[rustc_must_implement_one_of(read, read_buf)]
553
pub trait Read {
554
/// Pull some bytes from this source into the specified buffer, returning
555
/// how many bytes were read.
@@ -630,7 +631,10 @@ pub trait Read {
630
631
/// }
632
/// ```
633
- fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
634
+ fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
635
+ let mut buf = BorrowedBuf::from(buf);
636
+ self.read_buf(buf.unfilled()).map(|()| buf.len())
637
+ }
638
639
/// Like `read`, except that it reads into a slice of buffers.
640
///
0 commit comments