Open
Description
As of io_slice_advance is stable since 1.81, the following asserting may won't work if the users use IoSliceMut::advance in their impl of Read
trait.
fn what_to_read<R>(reader: R)
where
R: Read,
{
let mut b1 = [0u8; 16];
let mut b2 = [0u8; 32];
let mut iov = [IoSliceMut::new(&mut b1), IoSliceMut::new(&mut b2)];
let nr = reader.read_vectored(&mut iov).unwrap();
if nr > 0 {
assert_eq!(b1[0], iov[0][0]);
}
if nr >= b1.len() {
assert_eq!(iov[0].len(), b1.len());
}
}
It is unclear that whether the returned size of read_vectored
is the real read data size, or the valid buffer size in the passed &mut [IoSliceMut<'_>]
.
Please clarify that so Read
implementations can do the correct thing.
Metadata
Metadata
Assignees
Labels
Area: Documentation for any part of the project, including the compiler, standard library, and toolsArea: `std::io`, `std::fs`, `std::net` and `std::path`Category: Discussion or questions that doesn't represent real issues.Relevant to the library team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.