Skip to content

Commit 709ea74

Browse files
committed
Add Read Impl for &Stdin
1 parent 0250ef2 commit 709ea74

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

library/std/src/io/stdio.rs

+23
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,29 @@ impl Read for Stdin {
445445
}
446446
}
447447

448+
#[stable(feature = "rust1", since = "1.0.0")]
449+
impl Read for &Stdin {
450+
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
451+
self.lock().read(buf)
452+
}
453+
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
454+
self.lock().read_vectored(bufs)
455+
}
456+
#[inline]
457+
fn is_read_vectored(&self) -> bool {
458+
self.lock().is_read_vectored()
459+
}
460+
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
461+
self.lock().read_to_end(buf)
462+
}
463+
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
464+
self.lock().read_to_string(buf)
465+
}
466+
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
467+
self.lock().read_exact(buf)
468+
}
469+
}
470+
448471
// only used by platform-dependent io::copy specializations, i.e. unused on some platforms
449472
#[cfg(any(target_os = "linux", target_os = "android"))]
450473
impl StdinLock<'_> {

0 commit comments

Comments
 (0)