diff options
| author | bors <bors@rust-lang.org> | 2022-08-28 09:45:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-28 09:45:27 +0000 |
| commit | 3fdd578d72a24d4efc2fe2ad18eec3b6ba72271e (patch) | |
| tree | c16a91467031dd1db4408c338037e1a0206799cd /library/std/src/sys/unix | |
| parent | d5ef528bebbe0d8e350e547316fdc7d7476614d2 (diff) | |
| parent | b3a4bc51d7df23cde0ad96ee4dbd27c0f9311b82 (diff) | |
| download | rust-3fdd578d72a24d4efc2fe2ad18eec3b6ba72271e.tar.gz rust-3fdd578d72a24d4efc2fe2ad18eec3b6ba72271e.zip | |
Auto merge of #101115 - matthiaskrgr:rollup-iy14ztr, r=matthiaskrgr
Rollup of 13 pull requests Successful merges: - #97015 (std::io: migrate ReadBuf to BorrowBuf/BorrowCursor) - #98301 (Add GDB/LLDB pretty-printers for NonZero types) - #99570 (Box::from(slice): Clarify that contents are copied) - #100296 (Add standard C error function aliases to last_os_error) - #100520 (Add mention of `BufReader` in `Read::bytes` docs) - #100885 (Export Cancel from std::os::fortanix_sgx::usercalls::raw) - #100955 (Some papercuts on error::Error) - #101002 (Provide structured suggestion for `hashmap[idx] = val`) - #101038 (no alignment check during interning) - #101055 (Use smaller span for suggestions) - #101091 (Extend attrs if local_def_id exists) - #101098 (rustc_middle: Remove `Visibility::Invisible`) - #101102 (unstable-book-gen: use std::fs::write) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys/unix')
| -rw-r--r-- | library/std/src/sys/unix/fd.rs | 11 | ||||
| -rw-r--r-- | library/std/src/sys/unix/fs.rs | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs index 30812dabb4e..dbaa3c33e2e 100644 --- a/library/std/src/sys/unix/fd.rs +++ b/library/std/src/sys/unix/fd.rs @@ -4,7 +4,7 @@ mod tests; use crate::cmp; -use crate::io::{self, IoSlice, IoSliceMut, Read, ReadBuf}; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut, Read}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; use crate::sys::cvt; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -131,20 +131,19 @@ impl FileDesc { } } - pub fn read_buf(&self, buf: &mut ReadBuf<'_>) -> io::Result<()> { + pub fn read_buf(&self, mut cursor: BorrowedCursor<'_>) -> io::Result<()> { let ret = cvt(unsafe { libc::read( self.as_raw_fd(), - buf.unfilled_mut().as_mut_ptr() as *mut libc::c_void, - cmp::min(buf.remaining(), READ_LIMIT), + cursor.as_mut().as_mut_ptr() as *mut libc::c_void, + cmp::min(cursor.capacity(), READ_LIMIT), ) })?; // Safety: `ret` bytes were written to the initialized portion of the buffer unsafe { - buf.assume_init(ret as usize); + cursor.advance(ret as usize); } - buf.add_filled(ret as usize); Ok(()) } diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs index f38d2fd3d70..cc347e3586a 100644 --- a/library/std/src/sys/unix/fs.rs +++ b/library/std/src/sys/unix/fs.rs @@ -2,7 +2,7 @@ use crate::os::unix::prelude::*; use crate::ffi::{CStr, CString, OsStr, OsString}; use crate::fmt; -use crate::io::{self, Error, IoSlice, IoSliceMut, ReadBuf, SeekFrom}; +use crate::io::{self, BorrowedCursor, Error, IoSlice, IoSliceMut, SeekFrom}; use crate::mem; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd}; use crate::path::{Path, PathBuf}; @@ -1037,8 +1037,8 @@ impl File { self.0.read_at(buf, offset) } - pub fn read_buf(&self, buf: &mut ReadBuf<'_>) -> io::Result<()> { - self.0.read_buf(buf) + pub fn read_buf(&self, cursor: BorrowedCursor<'_>) -> io::Result<()> { + self.0.read_buf(cursor) } pub fn write(&self, buf: &[u8]) -> io::Result<usize> { |
