summaryrefslogtreecommitdiff
path: root/library/std/src/os/windows/io/handle.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/os/windows/io/handle.rs')
-rw-r--r--library/std/src/os/windows/io/handle.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs
index 280757a41a2..cbf8209a5ad 100644
--- a/library/std/src/os/windows/io/handle.rs
+++ b/library/std/src/os/windows/io/handle.rs
@@ -437,6 +437,42 @@ impl<T: AsHandle> AsHandle for &mut T {
}
}
+#[stable(feature = "as_windows_ptrs", since = "CURRENT_RUSTC_VERSION")]
+/// This impl allows implementing traits that require `AsHandle` on Arc.
+/// ```
+/// # #[cfg(windows)] mod group_cfg {
+/// # use std::os::windows::io::AsHandle;
+/// use std::fs::File;
+/// use std::sync::Arc;
+///
+/// trait MyTrait: AsHandle {}
+/// impl MyTrait for Arc<File> {}
+/// impl MyTrait for Box<File> {}
+/// # }
+/// ```
+impl<T: AsHandle> AsHandle for crate::sync::Arc<T> {
+ #[inline]
+ fn as_handle(&self) -> BorrowedHandle<'_> {
+ (**self).as_handle()
+ }
+}
+
+#[stable(feature = "as_windows_ptrs", since = "CURRENT_RUSTC_VERSION")]
+impl<T: AsHandle> AsHandle for crate::rc::Rc<T> {
+ #[inline]
+ fn as_handle(&self) -> BorrowedHandle<'_> {
+ (**self).as_handle()
+ }
+}
+
+#[stable(feature = "as_windows_ptrs", since = "CURRENT_RUSTC_VERSION")]
+impl<T: AsHandle> AsHandle for Box<T> {
+ #[inline]
+ fn as_handle(&self) -> BorrowedHandle<'_> {
+ (**self).as_handle()
+ }
+}
+
#[stable(feature = "io_safety", since = "1.63.0")]
impl AsHandle for BorrowedHandle<'_> {
#[inline]