Skip to content

Commit 8270a91

Browse files
authored
Change impl trait arguments to explicit generic parameters. (#1283)
As discussed [here], use generic parameters instead of impl trait argumentst. [here]: #753 (comment)
1 parent ce43fdd commit 8270a91

File tree

8 files changed

+51
-42
lines changed

8 files changed

+51
-42
lines changed

src/event/epoll.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ pub fn create(flags: epoll::CreateFlags) -> io::Result<OwnedFd> {
123123
/// [faq]: https://man7.org/linux/man-pages/man7/epoll.7.html#:~:text=Will%20closing%20a%20file%20descriptor%20cause%20it%20to%20be%20removed%20from%20all%0A%20%20%20%20%20%20%20%20%20%20epoll%20interest%20lists%3F
124124
#[doc(alias = "epoll_ctl")]
125125
#[inline]
126-
pub fn add(
127-
epoll: impl AsFd,
128-
source: impl AsFd,
126+
pub fn add<EpollFd: AsFd, SourceFd: AsFd>(
127+
epoll: EpollFd,
128+
source: SourceFd,
129129
data: epoll::EventData,
130130
event_flags: epoll::EventFlags,
131131
) -> io::Result<()> {
@@ -154,9 +154,9 @@ pub fn add(
154154
/// [illumos]: https://www.illumos.org/man/3C/epoll_ctl
155155
#[doc(alias = "epoll_ctl")]
156156
#[inline]
157-
pub fn modify(
158-
epoll: impl AsFd,
159-
source: impl AsFd,
157+
pub fn modify<EpollFd: AsFd, SourceFd: AsFd>(
158+
epoll: EpollFd,
159+
source: SourceFd,
160160
data: epoll::EventData,
161161
event_flags: epoll::EventFlags,
162162
) -> io::Result<()> {
@@ -183,7 +183,7 @@ pub fn modify(
183183
/// [illumos]: https://www.illumos.org/man/3C/epoll_ctl
184184
#[doc(alias = "epoll_ctl")]
185185
#[inline]
186-
pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
186+
pub fn delete<EpollFd: AsFd, SourceFd: AsFd>(epoll: EpollFd, source: SourceFd) -> io::Result<()> {
187187
syscalls::epoll_del(epoll.as_fd(), source.as_fd())
188188
}
189189

@@ -202,7 +202,11 @@ pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> {
202202
#[cfg(feature = "alloc")]
203203
#[cfg_attr(docsrs, doc(cfg(feature = "alloc"), alias = "epoll_wait"))]
204204
#[inline]
205-
pub fn wait(epoll: impl AsFd, event_list: &mut EventVec, timeout: c::c_int) -> io::Result<()> {
205+
pub fn wait<EpollFd: AsFd>(
206+
epoll: EpollFd,
207+
event_list: &mut EventVec,
208+
timeout: c::c_int,
209+
) -> io::Result<()> {
206210
// SAFETY: We're calling `epoll_wait` via FFI and we know how it
207211
// behaves.
208212
unsafe {

src/event/kqueue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ pub fn kqueue() -> io::Result<OwnedFd> {
415415
/// [OpenBSD]: https://man.openbsd.org/kevent.2
416416
/// [NetBSD]: https://man.netbsd.org/kevent.2
417417
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=kevent&section=2
418-
pub unsafe fn kevent(
419-
kqueue: impl AsFd,
418+
pub unsafe fn kevent<Fd: AsFd>(
419+
kqueue: Fd,
420420
changelist: &[Event],
421421
eventlist: &mut Vec<Event>,
422422
timeout: Option<Duration>,

src/event/port.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ pub fn port_create() -> io::Result<OwnedFd> {
5858
///
5959
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_associate/
6060
/// [illumos]: https://illumos.org/man/3C/port_associate
61-
pub unsafe fn port_associate_fd(
62-
port: impl AsFd,
63-
object: impl AsRawFd,
61+
pub unsafe fn port_associate_fd<Fd: AsFd, RawFd: AsRawFd>(
62+
port: Fd,
63+
object: RawFd,
6464
events: PollFlags,
6565
userdata: *mut ffi::c_void,
6666
) -> io::Result<()> {
@@ -87,7 +87,10 @@ pub unsafe fn port_associate_fd(
8787
///
8888
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_dissociate
8989
/// [illumos]: https://illumos.org/man/3C/port_dissociate
90-
pub unsafe fn port_dissociate_fd(port: impl AsFd, object: impl AsRawFd) -> io::Result<()> {
90+
pub unsafe fn port_dissociate_fd<Fd: AsFd, RawFd: AsRawFd>(
91+
port: Fd,
92+
object: RawFd,
93+
) -> io::Result<()> {
9194
syscalls::port_dissociate(port.as_fd(), c::PORT_SOURCE_FD, object.as_raw_fd() as _)
9295
}
9396

@@ -99,7 +102,7 @@ pub unsafe fn port_dissociate_fd(port: impl AsFd, object: impl AsRawFd) -> io::R
99102
///
100103
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_get/
101104
/// [illumos]: https://illumos.org/man/3C/port_get
102-
pub fn port_get(port: impl AsFd, timeout: Option<Duration>) -> io::Result<Event> {
105+
pub fn port_get<Fd: AsFd>(port: Fd, timeout: Option<Duration>) -> io::Result<Event> {
103106
let mut timeout = timeout.map(|timeout| c::timespec {
104107
tv_sec: timeout.as_secs().try_into().unwrap(),
105108
tv_nsec: timeout.subsec_nanos() as _,
@@ -125,8 +128,8 @@ pub fn port_get(port: impl AsFd, timeout: Option<Duration>) -> io::Result<Event>
125128
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_getn/
126129
/// [illumos]: https://illumos.org/man/3C/port_getn
127130
#[cfg(feature = "alloc")]
128-
pub fn port_getn(
129-
port: impl AsFd,
131+
pub fn port_getn<Fd: AsFd>(
132+
port: Fd,
130133
events: &mut Vec<Event>,
131134
min_events: usize,
132135
timeout: Option<Duration>,
@@ -157,7 +160,7 @@ pub fn port_getn(
157160
///
158161
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_getn/
159162
/// [illumos]: https://illumos.org/man/3C/port_getn
160-
pub fn port_getn_query(port: impl AsFd) -> io::Result<u32> {
163+
pub fn port_getn_query<Fd: AsFd>(port: Fd) -> io::Result<u32> {
161164
syscalls::port_getn_query(port.as_fd())
162165
}
163166

@@ -169,6 +172,6 @@ pub fn port_getn_query(port: impl AsFd) -> io::Result<u32> {
169172
///
170173
/// [OpenSolaris]: https://www.unix.com/man-page/opensolaris/3C/port_send/
171174
/// [illumos]: https://illumos.org/man/3C/port_send
172-
pub fn port_send(port: impl AsFd, events: i32, userdata: *mut ffi::c_void) -> io::Result<()> {
175+
pub fn port_send<Fd: AsFd>(port: Fd, events: i32, userdata: *mut ffi::c_void) -> io::Result<()> {
173176
syscalls::port_send(port.as_fd(), events, userdata.cast())
174177
}

src/fs/inotify.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ pub fn init(flags: inotify::CreateFlags) -> io::Result<OwnedFd> {
7171
/// application should keep track of this externally to avoid logic errors.
7272
#[doc(alias = "inotify_add_watch")]
7373
#[inline]
74-
pub fn add_watch<P: crate::path::Arg>(
75-
inot: impl AsFd,
74+
pub fn add_watch<P: crate::path::Arg, Fd: AsFd>(
75+
inot: Fd,
7676
path: P,
7777
flags: inotify::WatchFlags,
7878
) -> io::Result<i32> {
@@ -85,7 +85,7 @@ pub fn add_watch<P: crate::path::Arg>(
8585
/// [`inotify::add_watch`] and not previously have been removed.
8686
#[doc(alias = "inotify_rm_watch")]
8787
#[inline]
88-
pub fn remove_watch(inot: impl AsFd, wd: i32) -> io::Result<()> {
88+
pub fn remove_watch<Fd: AsFd>(inot: Fd, wd: i32) -> io::Result<()> {
8989
syscalls::inotify_rm_watch(inot.as_fd(), wd)
9090
}
9191

src/net/netdevice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use alloc::string::String;
3333
/// [Linux]: https://man7.org/linux/man-pages/man7/netdevice.7.html
3434
#[inline]
3535
#[doc(alias = "SIOCGIFINDEX")]
36-
pub fn name_to_index(fd: impl AsFd, if_name: &str) -> io::Result<u32> {
36+
pub fn name_to_index<Fd: AsFd>(fd: Fd, if_name: &str) -> io::Result<u32> {
3737
crate::backend::net::netdevice::name_to_index(fd, if_name)
3838
}
3939

@@ -50,7 +50,7 @@ pub fn name_to_index(fd: impl AsFd, if_name: &str) -> io::Result<u32> {
5050
#[inline]
5151
#[doc(alias = "SIOCGIFNAME")]
5252
#[cfg(feature = "alloc")]
53-
pub fn index_to_name(fd: impl AsFd, index: u32) -> io::Result<String> {
53+
pub fn index_to_name<Fd: AsFd>(fd: Fd, index: u32) -> io::Result<String> {
5454
crate::backend::net::netdevice::index_to_name(fd, index)
5555
}
5656

src/net/send_recv/msg.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ impl FusedIterator for AncillaryDrain<'_> {}
617617
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=sendmsg&section=2
618618
/// [illumos]: https://illumos.org/man/3SOCKET/sendmsg
619619
#[inline]
620-
pub fn sendmsg(
621-
socket: impl AsFd,
620+
pub fn sendmsg<Fd: AsFd>(
621+
socket: Fd,
622622
iov: &[IoSlice<'_>],
623623
control: &mut SendAncillaryBuffer<'_, '_, '_>,
624624
flags: SendFlags,
@@ -647,8 +647,8 @@ pub fn sendmsg(
647647
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=sendmsg&section=2
648648
/// [illumos]: https://illumos.org/man/3SOCKET/sendmsg
649649
#[inline]
650-
pub fn sendmsg_v4(
651-
socket: impl AsFd,
650+
pub fn sendmsg_v4<Fd: AsFd>(
651+
socket: Fd,
652652
addr: &SocketAddrV4,
653653
iov: &[IoSlice<'_>],
654654
control: &mut SendAncillaryBuffer<'_, '_, '_>,
@@ -678,8 +678,8 @@ pub fn sendmsg_v4(
678678
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=sendmsg&section=2
679679
/// [illumos]: https://illumos.org/man/3SOCKET/sendmsg
680680
#[inline]
681-
pub fn sendmsg_v6(
682-
socket: impl AsFd,
681+
pub fn sendmsg_v6<Fd: AsFd>(
682+
socket: Fd,
683683
addr: &SocketAddrV6,
684684
iov: &[IoSlice<'_>],
685685
control: &mut SendAncillaryBuffer<'_, '_, '_>,
@@ -711,8 +711,8 @@ pub fn sendmsg_v6(
711711
/// [illumos]: https://illumos.org/man/3SOCKET/sendmsg
712712
#[inline]
713713
#[cfg(unix)]
714-
pub fn sendmsg_unix(
715-
socket: impl AsFd,
714+
pub fn sendmsg_unix<Fd: AsFd>(
715+
socket: Fd,
716716
addr: &super::SocketAddrUnix,
717717
iov: &[IoSlice<'_>],
718718
control: &mut SendAncillaryBuffer<'_, '_, '_>,
@@ -729,8 +729,8 @@ pub fn sendmsg_unix(
729729
/// [Linux]: https://man7.org/linux/man-pages/man2/sendmsg.2.html
730730
#[inline]
731731
#[cfg(target_os = "linux")]
732-
pub fn sendmsg_xdp(
733-
socket: impl AsFd,
732+
pub fn sendmsg_xdp<Fd: AsFd>(
733+
socket: Fd,
734734
addr: &super::SocketAddrXdp,
735735
iov: &[IoSlice<'_>],
736736
control: &mut SendAncillaryBuffer<'_, '_, '_>,
@@ -760,8 +760,8 @@ pub fn sendmsg_xdp(
760760
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=sendmsg&section=2
761761
/// [illumos]: https://illumos.org/man/3SOCKET/sendmsg
762762
#[inline]
763-
pub fn sendmsg_any(
764-
socket: impl AsFd,
763+
pub fn sendmsg_any<Fd: AsFd>(
764+
socket: Fd,
765765
addr: Option<&SocketAddrAny>,
766766
iov: &[IoSlice<'_>],
767767
control: &mut SendAncillaryBuffer<'_, '_, '_>,
@@ -807,8 +807,8 @@ pub fn sendmsg_any(
807807
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=recvmsg&section=2
808808
/// [illumos]: https://illumos.org/man/3SOCKET/recvmsg
809809
#[inline]
810-
pub fn recvmsg(
811-
socket: impl AsFd,
810+
pub fn recvmsg<Fd: AsFd>(
811+
socket: Fd,
812812
iov: &mut [IoSliceMut<'_>],
813813
control: &mut RecvAncillaryBuffer<'_>,
814814
flags: RecvFlags,

src/process/prctl.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,10 @@ const PR_PAC_SET_ENABLED_KEYS: c_int = 60;
10911091
/// [`prctl(PR_PAC_SET_ENABLED_KEYS,…)`]: https://www.kernel.org/doc/html/v6.10/arch/arm64/pointer-authentication.html
10921092
#[inline]
10931093
#[doc(alias = "PR_PAC_SET_ENABLED_KEYS")]
1094-
pub unsafe fn configure_pointer_authentication_keys(
1095-
config: impl Iterator<Item = (PointerAuthenticationKeys, bool)>,
1094+
pub unsafe fn configure_pointer_authentication_keys<
1095+
Config: Iterator<Item = (PointerAuthenticationKeys, bool)>,
1096+
>(
1097+
config: Config,
10961098
) -> io::Result<()> {
10971099
let mut affected_keys: u32 = 0;
10981100
let mut enabled_keys: u32 = 0;

src/process/wait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ pub fn wait(waitopts: WaitOptions) -> io::Result<Option<(Pid, WaitStatus)>> {
361361
/// state.
362362
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "wasi")))]
363363
#[inline]
364-
pub fn waitid<'a>(
365-
id: impl Into<WaitId<'a>>,
364+
pub fn waitid<'a, Id: Into<WaitId<'a>>>(
365+
id: Id,
366366
options: WaitIdOptions,
367367
) -> io::Result<Option<WaitIdStatus>> {
368368
backend::process::syscalls::waitid(id.into(), options)

0 commit comments

Comments
 (0)