Skip to content

Commit 92cd909

Browse files
committed
take AsFd by value
1 parent 5ee09e7 commit 92cd909

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ mod sched_linux_like {
136136
/// reassociate thread with a namespace
137137
///
138138
/// See also [setns(2)](https://man7.org/linux/man-pages/man2/setns.2.html)
139-
pub fn setns<Fd: AsFd>(fd: &Fd, nstype: CloneFlags) -> Result<()> {
139+
pub fn setns<Fd: AsFd>(fd: Fd, nstype: CloneFlags) -> Result<()> {
140140
let res = unsafe { libc::setns(fd.as_fd().as_raw_fd(), nstype.bits()) };
141141

142142
Errno::result(res).map(drop)

src/sys/uio.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::os::unix::io::{AsFd, AsRawFd};
99
/// Low-level vectored write to a raw file descriptor
1010
///
1111
/// See also [writev(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/writev.html)
12-
pub fn writev<Fd: AsFd>(fd: &Fd, iov: &[IoSlice<'_>]) -> Result<usize> {
12+
pub fn writev<Fd: AsFd>(fd: Fd, iov: &[IoSlice<'_>]) -> Result<usize> {
1313
// SAFETY: to quote the documentation for `IoSlice`:
1414
//
1515
// [IoSlice] is semantically a wrapper around a &[u8], but is
@@ -27,7 +27,7 @@ pub fn writev<Fd: AsFd>(fd: &Fd, iov: &[IoSlice<'_>]) -> Result<usize> {
2727
/// Low-level vectored read from a raw file descriptor
2828
///
2929
/// See also [readv(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/readv.html)
30-
pub fn readv<Fd: AsFd>(fd: &Fd, iov: &mut [IoSliceMut<'_>]) -> Result<usize> {
30+
pub fn readv<Fd: AsFd>(fd: Fd, iov: &mut [IoSliceMut<'_>]) -> Result<usize> {
3131
// SAFETY: same as in writev(), IoSliceMut is ABI-compatible with iovec
3232
let res = unsafe {
3333
libc::readv(fd.as_fd().as_raw_fd(), iov.as_ptr() as *const libc::iovec, iov.len() as c_int)
@@ -44,7 +44,7 @@ pub fn readv<Fd: AsFd>(fd: &Fd, iov: &mut [IoSliceMut<'_>]) -> Result<usize> {
4444
/// See also: [`writev`](fn.writev.html) and [`pwrite`](fn.pwrite.html)
4545
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
4646
#[cfg_attr(docsrs, doc(cfg(all())))]
47-
pub fn pwritev<Fd: AsFd>(fd: &Fd, iov: &[IoSlice<'_>], offset: off_t) -> Result<usize> {
47+
pub fn pwritev<Fd: AsFd>(fd: Fd, iov: &[IoSlice<'_>], offset: off_t) -> Result<usize> {
4848
#[cfg(target_env = "uclibc")]
4949
let offset = offset as libc::off64_t; // uclibc doesn't use off_t
5050

@@ -71,7 +71,7 @@ pub fn pwritev<Fd: AsFd>(fd: &Fd, iov: &[IoSlice<'_>], offset: off_t) -> Result<
7171
#[cfg(not(any(target_os = "redox", target_os = "haiku")))]
7272
#[cfg_attr(docsrs, doc(cfg(all())))]
7373
pub fn preadv<Fd: AsFd>(
74-
fd: &Fd,
74+
fd: Fd,
7575
iov: &mut [IoSliceMut<'_>],
7676
offset: off_t,
7777
) -> Result<usize> {
@@ -95,7 +95,7 @@ pub fn preadv<Fd: AsFd>(
9595
///
9696
/// See also [pwrite(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html)
9797
// TODO: move to unistd
98-
pub fn pwrite<Fd: AsFd>(fd: &Fd, buf: &[u8], offset: off_t) -> Result<usize> {
98+
pub fn pwrite<Fd: AsFd>(fd: Fd, buf: &[u8], offset: off_t) -> Result<usize> {
9999
let res = unsafe {
100100
libc::pwrite(
101101
fd.as_fd().as_raw_fd(),
@@ -112,7 +112,7 @@ pub fn pwrite<Fd: AsFd>(fd: &Fd, buf: &[u8], offset: off_t) -> Result<usize> {
112112
///
113113
/// See also [pread(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html)
114114
// TODO: move to unistd
115-
pub fn pread<Fd: AsFd>(fd: &Fd, buf: &mut [u8], offset: off_t) -> Result<usize> {
115+
pub fn pread<Fd: AsFd>(fd: Fd, buf: &mut [u8], offset: off_t) -> Result<usize> {
116116
let res = unsafe {
117117
libc::pread(
118118
fd.as_fd().as_raw_fd(),

0 commit comments

Comments
 (0)