From 8ea292278aadcbd923e317fc39447fd6ad2f0b6c Mon Sep 17 00:00:00 2001 From: Gary Guo <gary@garyguo.net> Date: Wed, 9 Aug 2023 14:36:54 +0100 Subject: [PATCH 1/2] Make `impl<Fd: AsFd>` impl take `?Sized` --- library/std/src/os/fd/owned.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index 24f2bdcf4217c..06b3c4583bf1b 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -244,7 +244,7 @@ pub trait AsFd { } #[stable(feature = "io_safety", since = "1.63.0")] -impl<T: AsFd> AsFd for &T { +impl<T: AsFd + ?Sized> AsFd for &T { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { T::as_fd(self) @@ -252,7 +252,7 @@ impl<T: AsFd> AsFd for &T { } #[stable(feature = "io_safety", since = "1.63.0")] -impl<T: AsFd> AsFd for &mut T { +impl<T: AsFd + ?Sized> AsFd for &mut T { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { T::as_fd(self) @@ -396,7 +396,7 @@ impl From<OwnedFd> for crate::net::UdpSocket { /// impl MyTrait for Box<UdpSocket> {} /// # } /// ``` -impl<T: AsFd> AsFd for crate::sync::Arc<T> { +impl<T: AsFd + ?Sized> AsFd for crate::sync::Arc<T> { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { (**self).as_fd() @@ -404,7 +404,7 @@ impl<T: AsFd> AsFd for crate::sync::Arc<T> { } #[stable(feature = "asfd_rc", since = "1.69.0")] -impl<T: AsFd> AsFd for crate::rc::Rc<T> { +impl<T: AsFd + ?Sized> AsFd for crate::rc::Rc<T> { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { (**self).as_fd() @@ -412,7 +412,7 @@ impl<T: AsFd> AsFd for crate::rc::Rc<T> { } #[stable(feature = "asfd_ptrs", since = "1.64.0")] -impl<T: AsFd> AsFd for Box<T> { +impl<T: AsFd + ?Sized> AsFd for Box<T> { #[inline] fn as_fd(&self) -> BorrowedFd<'_> { (**self).as_fd() From f4aeb7030993f5c143e9a84c50061892f6b7046f Mon Sep 17 00:00:00 2001 From: Gary Guo <gary@garyguo.net> Date: Sun, 28 Jan 2024 23:31:55 +0000 Subject: [PATCH 2/2] Make `impl<T: AsHandle>` impl take `?Sized` --- library/std/src/os/windows/io/handle.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/std/src/os/windows/io/handle.rs b/library/std/src/os/windows/io/handle.rs index b0540872c0b62..55c3913904432 100644 --- a/library/std/src/os/windows/io/handle.rs +++ b/library/std/src/os/windows/io/handle.rs @@ -422,7 +422,7 @@ pub trait AsHandle { } #[stable(feature = "io_safety", since = "1.63.0")] -impl<T: AsHandle> AsHandle for &T { +impl<T: AsHandle + ?Sized> AsHandle for &T { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { T::as_handle(self) @@ -430,7 +430,7 @@ impl<T: AsHandle> AsHandle for &T { } #[stable(feature = "io_safety", since = "1.63.0")] -impl<T: AsHandle> AsHandle for &mut T { +impl<T: AsHandle + ?Sized> AsHandle for &mut T { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { T::as_handle(self) @@ -450,7 +450,7 @@ impl<T: AsHandle> AsHandle for &mut T { /// impl MyTrait for Box<File> {} /// # } /// ``` -impl<T: AsHandle> AsHandle for crate::sync::Arc<T> { +impl<T: AsHandle + ?Sized> AsHandle for crate::sync::Arc<T> { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { (**self).as_handle() @@ -458,7 +458,7 @@ impl<T: AsHandle> AsHandle for crate::sync::Arc<T> { } #[stable(feature = "as_windows_ptrs", since = "1.71.0")] -impl<T: AsHandle> AsHandle for crate::rc::Rc<T> { +impl<T: AsHandle + ?Sized> AsHandle for crate::rc::Rc<T> { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { (**self).as_handle() @@ -466,7 +466,7 @@ impl<T: AsHandle> AsHandle for crate::rc::Rc<T> { } #[stable(feature = "as_windows_ptrs", since = "1.71.0")] -impl<T: AsHandle> AsHandle for Box<T> { +impl<T: AsHandle + ?Sized> AsHandle for Box<T> { #[inline] fn as_handle(&self) -> BorrowedHandle<'_> { (**self).as_handle()