This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,39 @@ macro_rules! impl_owned_fd_traits {
271271}
272272impl_owned_fd_traits ! { TcpStream TcpListener UdpSocket }
273273
274+ /// This impl allows implementing traits that require `AsFd` on Arc.
275+ /// ```
276+ /// # #[cfg(target_os = "solid_asp3")] mod group_cfg {
277+ /// # use std::os::solid::io::AsFd;
278+ /// use std::net::UdpSocket;
279+ /// use std::sync::Arc;
280+ ///
281+ /// trait MyTrait: AsFd {}
282+ /// impl MyTrait for Arc<UdpSocket> {}
283+ /// impl MyTrait for Box<UdpSocket> {}
284+ /// # }
285+ /// ```
286+ impl < T : AsFd > AsFd for crate :: sync:: Arc < T > {
287+ #[ inline]
288+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
289+ ( * * self ) . as_fd ( )
290+ }
291+ }
292+
293+ impl < T : AsFd > AsFd for crate :: rc:: Rc < T > {
294+ #[ inline]
295+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
296+ ( * * self ) . as_fd ( )
297+ }
298+ }
299+
300+ impl < T : AsFd > AsFd for Box < T > {
301+ #[ inline]
302+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
303+ ( * * self ) . as_fd ( )
304+ }
305+ }
306+
274307/// A trait to extract the raw SOLID Sockets file descriptor from an underlying
275308/// object.
276309pub trait AsRawFd {
You can’t perform that action at this time.
0 commit comments