File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed
library/std/src/os/windows/io Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,42 @@ impl<T: AsHandle> AsHandle for &mut T {
437437 }
438438}
439439
440+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
441+ /// This impl allows implementing traits that require `AsHandle` on Arc.
442+ /// ```
443+ /// # #[cfg(windows)] mod group_cfg {
444+ /// # use std::os::windows::io::AsHandle;
445+ /// use std::fs::File;
446+ /// use std::sync::Arc;
447+ ///
448+ /// trait MyTrait: AsHandle {}
449+ /// impl MyTrait for Arc<File> {}
450+ /// impl MyTrait for Box<File> {}
451+ /// # }
452+ /// ```
453+ impl < T : AsHandle > AsHandle for crate :: sync:: Arc < T > {
454+ #[ inline]
455+ fn as_handle ( & self ) -> BorrowedHandle < ' _ > {
456+ ( * * self ) . as_handle ( )
457+ }
458+ }
459+
460+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
461+ impl < T : AsHandle > AsHandle for crate :: rc:: Rc < T > {
462+ #[ inline]
463+ fn as_handle ( & self ) -> BorrowedHandle < ' _ > {
464+ ( * * self ) . as_handle ( )
465+ }
466+ }
467+
468+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
469+ impl < T : AsHandle > AsHandle for Box < T > {
470+ #[ inline]
471+ fn as_handle ( & self ) -> BorrowedHandle < ' _ > {
472+ ( * * self ) . as_handle ( )
473+ }
474+ }
475+
440476#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
441477impl AsHandle for BorrowedHandle < ' _ > {
442478 #[ inline]
Original file line number Diff line number Diff line change @@ -247,6 +247,42 @@ impl<T: AsSocket> AsSocket for &mut T {
247247 }
248248}
249249
250+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
251+ /// This impl allows implementing traits that require `AsSocket` on Arc.
252+ /// ```
253+ /// # #[cfg(windows)] mod group_cfg {
254+ /// # use std::os::windows::io::AsSocket;
255+ /// use std::net::UdpSocket;
256+ /// use std::sync::Arc;
257+ ///
258+ /// trait MyTrait: AsSocket {}
259+ /// impl MyTrait for Arc<UdpSocket> {}
260+ /// impl MyTrait for Box<UdpSocket> {}
261+ /// # }
262+ /// ```
263+ impl < T : AsSocket > AsSocket for crate :: sync:: Arc < T > {
264+ #[ inline]
265+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
266+ ( * * self ) . as_socket ( )
267+ }
268+ }
269+
270+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
271+ impl < T : AsSocket > AsSocket for crate :: rc:: Rc < T > {
272+ #[ inline]
273+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
274+ ( * * self ) . as_socket ( )
275+ }
276+ }
277+
278+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
279+ impl < T : AsSocket > AsSocket for Box < T > {
280+ #[ inline]
281+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
282+ ( * * self ) . as_socket ( )
283+ }
284+ }
285+
250286#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
251287impl AsSocket for BorrowedSocket < ' _ > {
252288 #[ inline]
You can’t perform that action at this time.
0 commit comments