Skip to content
/ rust Public
forked from rust-lang/rust

Commit

Permalink
Rollup merge of rust-lang#99153 - Dajamante:issue/95622, r=dtolnay
Browse files Browse the repository at this point in the history
Add Read Impl for &Stdin

r? `@oli-obk`
fixes rust-lang#95622
  • Loading branch information
jhpratt authored Mar 9, 2024
2 parents 48a15aa + b18280f commit 286e813
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions library/std/src/io/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,32 @@ impl Read for Stdin {
}
}

#[stable(feature = "read_shared_stdin", since = "CURRENT_RUSTC_VERSION")]
impl Read for &Stdin {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.lock().read(buf)
}
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
self.lock().read_buf(buf)
}
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.lock().read_vectored(bufs)
}
#[inline]
fn is_read_vectored(&self) -> bool {
self.lock().is_read_vectored()
}
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> io::Result<usize> {
self.lock().read_to_end(buf)
}
fn read_to_string(&mut self, buf: &mut String) -> io::Result<usize> {
self.lock().read_to_string(buf)
}
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
self.lock().read_exact(buf)
}
}

// only used by platform-dependent io::copy specializations, i.e. unused on some platforms
#[cfg(any(target_os = "linux", target_os = "android"))]
impl StdinLock<'_> {
Expand Down

0 comments on commit 286e813

Please sign in to comment.