File tree 2 files changed +72
-0
lines changed
library/std/src/os/windows/io
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 {
437
437
}
438
438
}
439
439
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
+
440
476
#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
441
477
impl AsHandle for BorrowedHandle < ' _ > {
442
478
#[ inline]
Original file line number Diff line number Diff line change @@ -254,6 +254,42 @@ impl<T: AsSocket> AsSocket for &mut T {
254
254
}
255
255
}
256
256
257
+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
258
+ /// This impl allows implementing traits that require `AsSocket` on Arc.
259
+ /// ```
260
+ /// # #[cfg(windows)] mod group_cfg {
261
+ /// # use std::os::windows::io::AsSocket;
262
+ /// use std::net::UdpSocket;
263
+ /// use std::sync::Arc;
264
+ ///
265
+ /// trait MyTrait: AsSocket {}
266
+ /// impl MyTrait for Arc<UdpSocket> {}
267
+ /// impl MyTrait for Box<UdpSocket> {}
268
+ /// # }
269
+ /// ```
270
+ impl < T : AsSocket > AsSocket for crate :: sync:: Arc < T > {
271
+ #[ inline]
272
+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
273
+ ( * * self ) . as_socket ( )
274
+ }
275
+ }
276
+
277
+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
278
+ impl < T : AsSocket > AsSocket for crate :: rc:: Rc < T > {
279
+ #[ inline]
280
+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
281
+ ( * * self ) . as_socket ( )
282
+ }
283
+ }
284
+
285
+ #[ stable( feature = "as_windows_ptrs" , since = "CURRENT_RUSTC_VERSION" ) ]
286
+ impl < T : AsSocket > AsSocket for Box < T > {
287
+ #[ inline]
288
+ fn as_socket ( & self ) -> BorrowedSocket < ' _ > {
289
+ ( * * self ) . as_socket ( )
290
+ }
291
+ }
292
+
257
293
#[ stable( feature = "io_safety" , since = "1.63.0" ) ]
258
294
impl AsSocket for BorrowedSocket < ' _ > {
259
295
#[ inline]
You can’t perform that action at this time.
0 commit comments