Skip to content

Commit 5a2893a

Browse files
committed
Use the new impl AsFd for &T support in io-lifetimes.
With rust-lang/rust#93888 now in nightly, and sunfishcode/io-lifetimes#18 now in io-lifetimes 0.5.2, we can now simplify the `AsFd` pattern from `fn foo<Fd: AsFd>(fd: &Fd)` to `fn foo<Fd: AsFd>(fd: Fd)`, without the `&`. This also follows the emerging convention in std, as seen in the new [`fchown`] function. This means that users can now pass `BorrowedFd` values directly to functions that expect `AsFd` arguments, without having to write an extra `&` when passing them. [`fchown`]: https://doc.rust-lang.org/nightly/std/os/unix/fs/fn.fchown.html
1 parent 6dbc58c commit 5a2893a

24 files changed

+132
-131
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cc = { version = "1.0.68", optional = true }
2020
[dependencies]
2121
bitflags = "1.2.1"
2222
itoa = { version = "1.0.1", default-features = false, optional = true }
23-
io-lifetimes = { version = "0.5.1", default-features = false, optional = true }
23+
io-lifetimes = { version = "0.5.2", default-features = false, optional = true }
2424

2525
# Special dependencies used in rustc-dep-of-std mode.
2626
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }

examples/stdio.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ fn main() -> io::Result<()> {
2525
}
2626

2727
#[cfg(not(windows))]
28-
fn show<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
28+
fn show<Fd: AsFd>(fd: Fd) -> io::Result<()> {
29+
let fd = fd.as_fd();
2930
if isatty(fd) {
3031
#[cfg(any(all(linux_raw, feature = "procfs"), libc))]
3132
println!(" - ttyname: {}", ttyname(fd, Vec::new())?.to_string_lossy());

src/fs/at.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use imp::fs::{Dev, FileType};
4040
/// [Linux]: https://man7.org/linux/man-pages/man2/open.2.html
4141
#[inline]
4242
pub fn openat<P: path::Arg, Fd: AsFd>(
43-
dirfd: &Fd,
43+
dirfd: Fd,
4444
path: P,
4545
oflags: OFlags,
4646
create_mode: Mode,
@@ -60,7 +60,7 @@ pub fn openat<P: path::Arg, Fd: AsFd>(
6060
/// [Linux]: https://man7.org/linux/man-pages/man2/readlinkat.2.html
6161
#[inline]
6262
pub fn readlinkat<P: path::Arg, Fd: AsFd, B: Into<Vec<u8>>>(
63-
dirfd: &Fd,
63+
dirfd: Fd,
6464
path: P,
6565
reuse: B,
6666
) -> io::Result<ZString> {
@@ -97,7 +97,7 @@ fn _readlinkat(dirfd: BorrowedFd<'_>, path: &ZStr, mut buffer: Vec<u8>) -> io::R
9797
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdirat.html
9898
/// [Linux]: https://man7.org/linux/man-pages/man2/mkdirat.2.html
9999
#[inline]
100-
pub fn mkdirat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, mode: Mode) -> io::Result<()> {
100+
pub fn mkdirat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, mode: Mode) -> io::Result<()> {
101101
path.into_with_z_str(|path| imp::fs::syscalls::mkdirat(dirfd.as_fd(), path, mode))
102102
}
103103

@@ -112,9 +112,9 @@ pub fn mkdirat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, mode: Mode) -> io::R
112112
/// [Linux]: https://man7.org/linux/man-pages/man2/linkat.2.html
113113
#[inline]
114114
pub fn linkat<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
115-
old_dirfd: &PFd,
115+
old_dirfd: PFd,
116116
old_path: P,
117-
new_dirfd: &QFd,
117+
new_dirfd: QFd,
118118
new_path: Q,
119119
flags: AtFlags,
120120
) -> io::Result<()> {
@@ -144,7 +144,7 @@ pub fn linkat<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
144144
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html
145145
/// [Linux]: https://man7.org/linux/man-pages/man2/unlinkat.2.html
146146
#[inline]
147-
pub fn unlinkat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, flags: AtFlags) -> io::Result<()> {
147+
pub fn unlinkat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, flags: AtFlags) -> io::Result<()> {
148148
path.into_with_z_str(|path| imp::fs::syscalls::unlinkat(dirfd.as_fd(), path, flags))
149149
}
150150

@@ -159,9 +159,9 @@ pub fn unlinkat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, flags: AtFlags) ->
159159
/// [Linux]: https://man7.org/linux/man-pages/man2/renameat.2.html
160160
#[inline]
161161
pub fn renameat<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
162-
old_dirfd: &PFd,
162+
old_dirfd: PFd,
163163
old_path: P,
164-
new_dirfd: &QFd,
164+
new_dirfd: QFd,
165165
new_path: Q,
166166
) -> io::Result<()> {
167167
old_path.into_with_z_str(|old_path| {
@@ -182,9 +182,9 @@ pub fn renameat<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
182182
#[inline]
183183
#[doc(alias = "renameat2")]
184184
pub fn renameat_with<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
185-
old_dirfd: &PFd,
185+
old_dirfd: PFd,
186186
old_path: P,
187-
new_dirfd: &QFd,
187+
new_dirfd: QFd,
188188
new_path: Q,
189189
flags: RenameFlags,
190190
) -> io::Result<()> {
@@ -212,7 +212,7 @@ pub fn renameat_with<P: path::Arg, Q: path::Arg, PFd: AsFd, QFd: AsFd>(
212212
#[inline]
213213
pub fn symlinkat<P: path::Arg, Q: path::Arg, Fd: AsFd>(
214214
old_path: P,
215-
new_dirfd: &Fd,
215+
new_dirfd: Fd,
216216
new_path: Q,
217217
) -> io::Result<()> {
218218
old_path.into_with_z_str(|old_path| {
@@ -237,7 +237,7 @@ pub fn symlinkat<P: path::Arg, Q: path::Arg, Fd: AsFd>(
237237
/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode
238238
#[inline]
239239
#[doc(alias = "fstatat")]
240-
pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, flags: AtFlags) -> io::Result<Stat> {
240+
pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, flags: AtFlags) -> io::Result<Stat> {
241241
path.into_with_z_str(|path| imp::fs::syscalls::statat(dirfd.as_fd(), path, flags))
242242
}
243243

@@ -254,7 +254,7 @@ pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, flags: AtFlags) -> io
254254
#[inline]
255255
#[doc(alias = "faccessat")]
256256
pub fn accessat<P: path::Arg, Fd: AsFd>(
257-
dirfd: &Fd,
257+
dirfd: Fd,
258258
path: P,
259259
access: Access,
260260
flags: AtFlags,
@@ -272,7 +272,7 @@ pub fn accessat<P: path::Arg, Fd: AsFd>(
272272
/// [Linux]: https://man7.org/linux/man-pages/man2/utimensat.2.html
273273
#[inline]
274274
pub fn utimensat<P: path::Arg, Fd: AsFd>(
275-
dirfd: &Fd,
275+
dirfd: Fd,
276276
path: P,
277277
times: &Timestamps,
278278
flags: AtFlags,
@@ -297,7 +297,7 @@ pub fn utimensat<P: path::Arg, Fd: AsFd>(
297297
#[cfg(not(target_os = "wasi"))]
298298
#[inline]
299299
#[doc(alias = "fchmodat")]
300-
pub fn chmodat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, mode: Mode) -> io::Result<()> {
300+
pub fn chmodat<P: path::Arg, Fd: AsFd>(dirfd: Fd, path: P, mode: Mode) -> io::Result<()> {
301301
path.into_with_z_str(|path| imp::fs::syscalls::chmodat(dirfd.as_fd(), path, mode))
302302
}
303303

@@ -331,7 +331,7 @@ pub fn fclonefileat<Fd: AsFd, DstFd: AsFd, P: path::Arg>(
331331
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
332332
#[inline]
333333
pub fn mknodat<P: path::Arg, Fd: AsFd>(
334-
dirfd: &Fd,
334+
dirfd: Fd,
335335
path: P,
336336
file_type: FileType,
337337
mode: Mode,
@@ -354,7 +354,7 @@ pub fn mknodat<P: path::Arg, Fd: AsFd>(
354354
#[cfg(not(any(target_os = "wasi")))]
355355
#[inline]
356356
pub fn chownat<P: path::Arg, Fd: AsFd>(
357-
dirfd: &Fd,
357+
dirfd: Fd,
358358
path: P,
359359
owner: Uid,
360360
group: Gid,

src/fs/fadvise.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ pub use imp::fs::Advice;
1414
/// [Linux]: https://man7.org/linux/man-pages/man2/posix_fadvise.2.html
1515
#[inline]
1616
#[doc(alias = "posix_fadvise")]
17-
pub fn fadvise<Fd: AsFd>(fd: &Fd, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
17+
pub fn fadvise<Fd: AsFd>(fd: Fd, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
1818
imp::fs::syscalls::fadvise(fd.as_fd(), offset, len, advice)
1919
}

src/fs/fcntl.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use imp::fs::{FdFlags, OFlags};
1818
/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html
1919
#[inline]
2020
#[doc(alias = "F_GETFD")]
21-
pub fn fcntl_getfd<Fd: AsFd>(fd: &Fd) -> io::Result<FdFlags> {
21+
pub fn fcntl_getfd<Fd: AsFd>(fd: Fd) -> io::Result<FdFlags> {
2222
imp::fs::syscalls::fcntl_getfd(fd.as_fd())
2323
}
2424

@@ -32,7 +32,7 @@ pub fn fcntl_getfd<Fd: AsFd>(fd: &Fd) -> io::Result<FdFlags> {
3232
/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html
3333
#[inline]
3434
#[doc(alias = "F_SETFD")]
35-
pub fn fcntl_setfd<Fd: AsFd>(fd: &Fd, flags: FdFlags) -> io::Result<()> {
35+
pub fn fcntl_setfd<Fd: AsFd>(fd: Fd, flags: FdFlags) -> io::Result<()> {
3636
imp::fs::syscalls::fcntl_setfd(fd.as_fd(), flags)
3737
}
3838

@@ -46,7 +46,7 @@ pub fn fcntl_setfd<Fd: AsFd>(fd: &Fd, flags: FdFlags) -> io::Result<()> {
4646
/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html
4747
#[inline]
4848
#[doc(alias = "F_GETFL")]
49-
pub fn fcntl_getfl<Fd: AsFd>(fd: &Fd) -> io::Result<OFlags> {
49+
pub fn fcntl_getfl<Fd: AsFd>(fd: Fd) -> io::Result<OFlags> {
5050
imp::fs::syscalls::fcntl_getfl(fd.as_fd())
5151
}
5252

@@ -60,7 +60,7 @@ pub fn fcntl_getfl<Fd: AsFd>(fd: &Fd) -> io::Result<OFlags> {
6060
/// [Linux]: https://man7.org/linux/man-pages/man2/fcntl.2.html
6161
#[inline]
6262
#[doc(alias = "F_SETFL")]
63-
pub fn fcntl_setfl<Fd: AsFd>(fd: &Fd, flags: OFlags) -> io::Result<()> {
63+
pub fn fcntl_setfl<Fd: AsFd>(fd: Fd, flags: OFlags) -> io::Result<()> {
6464
imp::fs::syscalls::fcntl_setfl(fd.as_fd(), flags)
6565
}
6666

@@ -78,7 +78,7 @@ pub fn fcntl_setfl<Fd: AsFd>(fd: &Fd, flags: OFlags) -> io::Result<()> {
7878
))]
7979
#[inline]
8080
#[doc(alias = "F_GET_SEALS")]
81-
pub fn fcntl_get_seals<Fd: AsFd>(fd: &Fd) -> io::Result<SealFlags> {
81+
pub fn fcntl_get_seals<Fd: AsFd>(fd: Fd) -> io::Result<SealFlags> {
8282
imp::fs::syscalls::fcntl_get_seals(fd.as_fd())
8383
}
8484

@@ -104,7 +104,7 @@ pub use imp::fs::SealFlags;
104104
))]
105105
#[inline]
106106
#[doc(alias = "F_ADD_SEALS")]
107-
pub fn fcntl_add_seals<Fd: AsFd>(fd: &Fd, seals: SealFlags) -> io::Result<()> {
107+
pub fn fcntl_add_seals<Fd: AsFd>(fd: Fd, seals: SealFlags) -> io::Result<()> {
108108
imp::fs::syscalls::fcntl_add_seals(fd.as_fd(), seals)
109109
}
110110

@@ -126,6 +126,6 @@ pub fn fcntl_add_seals<Fd: AsFd>(fd: &Fd, seals: SealFlags) -> io::Result<()> {
126126
#[cfg(not(target_os = "wasi"))]
127127
#[inline]
128128
#[doc(alias = "F_DUPFD_CLOEXEC")]
129-
pub fn fcntl_dupfd_cloexec<Fd: AsFd>(fd: &Fd, min: RawFd) -> io::Result<OwnedFd> {
129+
pub fn fcntl_dupfd_cloexec<Fd: AsFd>(fd: Fd, min: RawFd) -> io::Result<OwnedFd> {
130130
imp::fs::syscalls::fcntl_dupfd_cloexec(fd.as_fd(), min)
131131
}

src/fs/fcntl_darwin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use imp::fd::AsFd;
88
///
99
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html
1010
#[inline]
11-
pub fn fcntl_rdadvise<Fd: AsFd>(fd: &Fd, offset: u64, len: u64) -> io::Result<()> {
11+
pub fn fcntl_rdadvise<Fd: AsFd>(fd: Fd, offset: u64, len: u64) -> io::Result<()> {
1212
imp::fs::syscalls::fcntl_rdadvise(fd.as_fd(), offset, len)
1313
}
1414

@@ -19,6 +19,6 @@ pub fn fcntl_rdadvise<Fd: AsFd>(fd: &Fd, offset: u64, len: u64) -> io::Result<()
1919
///
2020
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html
2121
#[inline]
22-
pub fn fcntl_fullfsync<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
22+
pub fn fcntl_fullfsync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
2323
imp::fs::syscalls::fcntl_fullfsync(fd.as_fd())
2424
}

src/fs/fd.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use imp::fs::{FlockOperation, Mode};
3535
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html
3636
/// [Linux]: https://man7.org/linux/man-pages/man2/lseek.2.html
3737
#[inline]
38-
pub fn seek<Fd: AsFd>(fd: &Fd, pos: SeekFrom) -> io::Result<u64> {
38+
pub fn seek<Fd: AsFd>(fd: Fd, pos: SeekFrom) -> io::Result<u64> {
3939
imp::fs::syscalls::seek(fd.as_fd(), pos)
4040
}
4141

@@ -52,7 +52,7 @@ pub fn seek<Fd: AsFd>(fd: &Fd, pos: SeekFrom) -> io::Result<u64> {
5252
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html
5353
/// [Linux]: https://man7.org/linux/man-pages/man2/lseek.2.html
5454
#[inline]
55-
pub fn tell<Fd: AsFd>(fd: &Fd) -> io::Result<u64> {
55+
pub fn tell<Fd: AsFd>(fd: Fd) -> io::Result<u64> {
5656
imp::fs::syscalls::tell(fd.as_fd())
5757
}
5858

@@ -69,7 +69,7 @@ pub fn tell<Fd: AsFd>(fd: &Fd) -> io::Result<u64> {
6969
/// [Linux]: https://man7.org/linux/man-pages/man2/fchmod.2.html
7070
#[cfg(not(target_os = "wasi"))]
7171
#[inline]
72-
pub fn fchmod<Fd: AsFd>(fd: &Fd, mode: Mode) -> io::Result<()> {
72+
pub fn fchmod<Fd: AsFd>(fd: Fd, mode: Mode) -> io::Result<()> {
7373
imp::fs::syscalls::fchmod(fd.as_fd(), mode)
7474
}
7575

@@ -83,7 +83,7 @@ pub fn fchmod<Fd: AsFd>(fd: &Fd, mode: Mode) -> io::Result<()> {
8383
/// [Linux]: https://man7.org/linux/man-pages/man2/fchown.2.html
8484
#[cfg(not(target_os = "wasi"))]
8585
#[inline]
86-
pub fn fchown<Fd: AsFd>(fd: &Fd, owner: Uid, group: Gid) -> io::Result<()> {
86+
pub fn fchown<Fd: AsFd>(fd: Fd, owner: Uid, group: Gid) -> io::Result<()> {
8787
imp::fs::syscalls::fchown(fd.as_fd(), owner, group)
8888
}
8989

@@ -101,7 +101,7 @@ pub fn fchown<Fd: AsFd>(fd: &Fd, owner: Uid, group: Gid) -> io::Result<()> {
101101
/// [`Mode::from_raw_mode`]: crate::fs::Mode::from_raw_mode
102102
/// [`FileType::from_raw_mode`]: crate::fs::FileType::from_raw_mode
103103
#[inline]
104-
pub fn fstat<Fd: AsFd>(fd: &Fd) -> io::Result<Stat> {
104+
pub fn fstat<Fd: AsFd>(fd: Fd) -> io::Result<Stat> {
105105
imp::fs::syscalls::fstat(fd.as_fd())
106106
}
107107

@@ -118,7 +118,7 @@ pub fn fstat<Fd: AsFd>(fd: &Fd) -> io::Result<Stat> {
118118
target_os = "wasi"
119119
)))] // not implemented in libc for netbsd yet
120120
#[inline]
121-
pub fn fstatfs<Fd: AsFd>(fd: &Fd) -> io::Result<StatFs> {
121+
pub fn fstatfs<Fd: AsFd>(fd: Fd) -> io::Result<StatFs> {
122122
imp::fs::syscalls::fstatfs(fd.as_fd())
123123
}
124124

@@ -131,7 +131,7 @@ pub fn fstatfs<Fd: AsFd>(fd: &Fd) -> io::Result<StatFs> {
131131
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html
132132
/// [Linux]: https://man7.org/linux/man-pages/man2/utimensat.2.html
133133
#[inline]
134-
pub fn futimens<Fd: AsFd>(fd: &Fd, times: &Timestamps) -> io::Result<()> {
134+
pub fn futimens<Fd: AsFd>(fd: Fd, times: &Timestamps) -> io::Result<()> {
135135
imp::fs::syscalls::futimens(fd.as_fd(), times)
136136
}
137137

@@ -159,7 +159,7 @@ pub fn futimens<Fd: AsFd>(fd: &Fd, times: &Timestamps) -> io::Result<()> {
159159
)))] // not implemented in libc for netbsd yet
160160
#[inline]
161161
#[doc(alias = "posix_fallocate")]
162-
pub fn fallocate<Fd: AsFd>(fd: &Fd, mode: FallocateFlags, offset: u64, len: u64) -> io::Result<()> {
162+
pub fn fallocate<Fd: AsFd>(fd: Fd, mode: FallocateFlags, offset: u64, len: u64) -> io::Result<()> {
163163
imp::fs::syscalls::fallocate(fd.as_fd(), mode, offset, len)
164164
}
165165

@@ -170,7 +170,7 @@ pub fn fallocate<Fd: AsFd>(fd: &Fd, mode: FallocateFlags, offset: u64, len: u64)
170170
/// example, it doesn't reflect whether sockets have been shut down; for
171171
/// general I/O handle support, use [`io::is_read_write`].
172172
#[inline]
173-
pub fn is_file_read_write<Fd: AsFd>(fd: &Fd) -> io::Result<(bool, bool)> {
173+
pub fn is_file_read_write<Fd: AsFd>(fd: Fd) -> io::Result<(bool, bool)> {
174174
_is_file_read_write(fd.as_fd())
175175
}
176176

@@ -212,7 +212,7 @@ pub(crate) fn _is_file_read_write(fd: BorrowedFd<'_>) -> io::Result<(bool, bool)
212212
/// [Linux]: https://man7.org/linux/man-pages/man2/fsync.2.html
213213
/// [`fcntl_fullfsync`]: https://docs.rs/rustix/*/x86_64-apple-darwin/rustix/fs/fn.fcntl_fullfsync.html
214214
#[inline]
215-
pub fn fsync<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
215+
pub fn fsync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
216216
imp::fs::syscalls::fsync(fd.as_fd())
217217
}
218218

@@ -232,7 +232,7 @@ pub fn fsync<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
232232
target_os = "redox"
233233
)))]
234234
#[inline]
235-
pub fn fdatasync<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
235+
pub fn fdatasync<Fd: AsFd>(fd: Fd) -> io::Result<()> {
236236
imp::fs::syscalls::fdatasync(fd.as_fd())
237237
}
238238

@@ -245,7 +245,7 @@ pub fn fdatasync<Fd: AsFd>(fd: &Fd) -> io::Result<()> {
245245
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
246246
/// [Linux]: https://man7.org/linux/man-pages/man2/ftruncate.2.html
247247
#[inline]
248-
pub fn ftruncate<Fd: AsFd>(fd: &Fd, length: u64) -> io::Result<()> {
248+
pub fn ftruncate<Fd: AsFd>(fd: Fd, length: u64) -> io::Result<()> {
249249
imp::fs::syscalls::ftruncate(fd.as_fd(), length)
250250
}
251251

@@ -257,6 +257,6 @@ pub fn ftruncate<Fd: AsFd>(fd: &Fd, length: u64) -> io::Result<()> {
257257
/// [Linux]: https://man7.org/linux/man-pages/man2/flock.2.html
258258
#[cfg(not(target_os = "wasi"))]
259259
#[inline]
260-
pub fn flock<Fd: AsFd>(fd: &Fd, operation: FlockOperation) -> io::Result<()> {
260+
pub fn flock<Fd: AsFd>(fd: Fd, operation: FlockOperation) -> io::Result<()> {
261261
imp::fs::syscalls::flock(fd.as_fd(), operation)
262262
}

src/fs/getpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ use imp::fd::AsFd;
99
///
1010
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html
1111
#[inline]
12-
pub fn getpath<Fd: AsFd>(fd: &Fd) -> io::Result<ZString> {
12+
pub fn getpath<Fd: AsFd>(fd: Fd) -> io::Result<ZString> {
1313
imp::fs::syscalls::getpath(fd.as_fd())
1414
}

src/fs/openat2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use imp::fs::{Mode, OFlags, ResolveFlags};
1111
/// [Linux]: https://man7.org/linux/man-pages/man2/openat2.2.html
1212
#[inline]
1313
pub fn openat2<Fd: AsFd, P: path::Arg>(
14-
dirfd: &Fd,
14+
dirfd: Fd,
1515
path: P,
1616
oflags: OFlags,
1717
mode: Mode,

src/fs/sendfile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use imp::fd::AsFd;
1010
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
1111
#[inline]
1212
pub fn sendfile<OutFd: AsFd, InFd: AsFd>(
13-
out_fd: &OutFd,
14-
in_fd: &InFd,
13+
out_fd: OutFd,
14+
in_fd: InFd,
1515
offset: Option<&mut u64>,
1616
count: usize,
1717
) -> io::Result<usize> {

src/fs/statx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use imp::fs::StatxFlags;
1818
/// [Linux]: https://man7.org/linux/man-pages/man2/statx.2.html
1919
#[inline]
2020
pub fn statx<P: path::Arg, Fd: AsFd>(
21-
dirfd: &Fd,
21+
dirfd: Fd,
2222
path: P,
2323
flags: AtFlags,
2424
mask: StatxFlags,

0 commit comments

Comments
 (0)