File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -355,3 +355,34 @@ impl From<OwnedFd> for crate::net::UdpSocket {
355355 ) ) ) )
356356 }
357357}
358+
359+ #[ stable( feature = "io_safety" , since = "1.63.0" ) ]
360+ /// This impl allows implementing traits that require `AsFd` on Arc.
361+ /// ```
362+ /// # #[cfg(any(unix, target_os = "wasi"))] mod group_cfg {
363+ /// # #[cfg(target_os = "wasi")]
364+ /// # use std::os::wasi::io::AsFd;
365+ /// # #[cfg(unix)]
366+ /// # use std::os::unix::io::AsFd;
367+ /// use std::net::UdpSocket;
368+ /// use std::sync::Arc;
369+ ///
370+ /// trait MyTrait: AsFd {}
371+ /// impl MyTrait for Arc<UdpSocket> {}
372+ /// impl MyTrait for Box<UdpSocket> {}
373+ /// # }
374+ /// ```
375+ impl < T : AsFd > AsFd for crate :: sync:: Arc < T > {
376+ #[ inline]
377+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
378+ ( * * self ) . as_fd ( )
379+ }
380+ }
381+
382+ #[ stable( feature = "io_safety" , since = "1.63.0" ) ]
383+ impl < T : AsFd > AsFd for Box < T > {
384+ #[ inline]
385+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
386+ ( * * self ) . as_fd ( )
387+ }
388+ }
Original file line number Diff line number Diff line change @@ -223,8 +223,7 @@ impl<'a> AsRawFd for io::StderrLock<'a> {
223223 }
224224}
225225
226- #[ stable( feature = "asraw_ptrs" , since = "1.63.0" ) ]
227- /// This blanket impl allows implementing custom traits that require `AsRawFd` on Arc.
226+ /// This impl allows implementing traits that require `AsRawFd` on Arc.
228227/// ```
229228/// # #[cfg(any(unix, target_os = "wasi"))] mod group_cfg {
230229/// # #[cfg(target_os = "wasi")]
@@ -247,7 +246,7 @@ impl<T: AsRawFd> AsRawFd for crate::sync::Arc<T> {
247246 }
248247}
249248
250- #[ stable( feature = "asraw_ptrs " , since = "1.63.0" ) ]
249+ #[ stable( feature = "asrawfd_ptrs " , since = "1.63.0" ) ]
251250impl < T : AsRawFd > AsRawFd for Box < T > {
252251 #[ inline]
253252 fn as_raw_fd ( & self ) -> RawFd {
You can’t perform that action at this time.
0 commit comments