Skip to content

Commit c54ff05

Browse files
committed
Make preadv take immutable slice of IoVecs, fixes #913
1 parent 8a9b86e commit c54ff05

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
### Added
99

1010
### Changed
11+
- Made `preadv` take immutable slice of IoVec. ([issue #913](https://github.com/nix-rust/nix/issues/913))
1112

1213
### Fixed
1314

src/sys/uio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn pwritev(fd: RawFd, iov: &[IoVec<&[u8]>],
5151
target_os = "linux",
5252
target_os = "netbsd",
5353
target_os = "openbsd"))]
54-
pub fn preadv(fd: RawFd, iov: &mut [IoVec<&mut [u8]>],
54+
pub fn preadv(fd: RawFd, iov: &[IoVec<&mut [u8]>],
5555
offset: off_t) -> Result<usize> {
5656
let res = unsafe {
5757
libc::preadv(fd, iov.as_ptr() as *const libc::iovec, iov.len() as c_int, offset)

test/sys/test_uio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ fn test_preadv() {
182182

183183
{
184184
// Borrow the buffers into IoVecs and preadv into them
185-
let mut iovecs: Vec<_> = buffers.iter_mut().map(
185+
let iovecs: Vec<_> = buffers.iter_mut().map(
186186
|buf| IoVec::from_mut_slice(&mut buf[..])).collect();
187-
assert_eq!(Ok(100), preadv(file.as_raw_fd(), &mut iovecs, 100));
187+
assert_eq!(Ok(100), preadv(file.as_raw_fd(), &iovecs, 100));
188188
}
189189

190190
let all = buffers.concat();

0 commit comments

Comments
 (0)