Skip to content

Commit a385768

Browse files
authored
Unrolled build for rust-lang#137353
Rollup merge of rust-lang#137353 - thaliaarchi:io-optional-methods/wasi-stdin, r=alexcrichton Implement `read_buf` for WASI stdin `WasiFd::read_buf` already exists. Simply use it in `Stdin`. cc `@alexcrichton` Tracked in rust-lang#136756
2 parents 71e06b9 + d32eeb8 commit a385768

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/std/src/sys/pal/wasi/stdio.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::fd::WasiFd;
4-
use crate::io::{self, IoSlice, IoSliceMut};
4+
use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
55
use crate::mem::ManuallyDrop;
66
use crate::os::raw;
77
use crate::os::wasi::io::{AsRawFd, FromRawFd};
@@ -28,6 +28,10 @@ impl io::Read for Stdin {
2828
self.read_vectored(&mut [IoSliceMut::new(data)])
2929
}
3030

31+
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
32+
ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read_buf(buf)
33+
}
34+
3135
fn read_vectored(&mut self, data: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
3236
ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read(data)
3337
}
@@ -64,6 +68,7 @@ impl io::Write for Stdout {
6468
fn is_write_vectored(&self) -> bool {
6569
true
6670
}
71+
6772
fn flush(&mut self) -> io::Result<()> {
6873
Ok(())
6974
}

0 commit comments

Comments
 (0)