diff options
| author | Ian Douglas Scott <ian@iandouglasscott.com> | 2023-01-25 17:15:59 -0800 |
|---|---|---|
| committer | Ian Douglas Scott <ian@iandouglasscott.com> | 2023-01-26 08:08:13 -0800 |
| commit | c13669e00b4ba3f353ea1cfa825aecb0bb765f9c (patch) | |
| tree | ce5a0b50be116ca36a99886168ddcd0ed6b77b44 | |
| parent | 40fda7b3fe2b10c6e1a0568b59516f5e7f381886 (diff) | |
| download | rust-c13669e00b4ba3f353ea1cfa825aecb0bb765f9c.tar.gz rust-c13669e00b4ba3f353ea1cfa825aecb0bb765f9c.zip | |
Implement `AsFd` and `AsRawFd` for `Rc`
Fixes https://github.com/rust-lang/rust/issues/105931.
| -rw-r--r-- | library/std/src/os/fd/owned.rs | 8 | ||||
| -rw-r--r-- | library/std/src/os/fd/raw.rs | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index c41e093a7e5..439b8d52a2d 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -396,6 +396,14 @@ impl<T: AsFd> AsFd for crate::sync::Arc<T> { } } +#[stable(feature = "asfd_rc", since = "CURRENT_RUSTC_VERSION")] +impl<T: AsFd> AsFd for crate::rc::Rc<T> { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + (**self).as_fd() + } +} + #[stable(feature = "asfd_ptrs", since = "1.64.0")] impl<T: AsFd> AsFd for Box<T> { #[inline] diff --git a/library/std/src/os/fd/raw.rs b/library/std/src/os/fd/raw.rs index f92a0506670..c138162f1ab 100644 --- a/library/std/src/os/fd/raw.rs +++ b/library/std/src/os/fd/raw.rs @@ -244,6 +244,14 @@ impl<T: AsRawFd> AsRawFd for crate::sync::Arc<T> { } } +#[stable(feature = "asfd_rc", since = "CURRENT_RUSTC_VERSION")] +impl<T: AsRawFd> AsRawFd for crate::rc::Rc<T> { + #[inline] + fn as_raw_fd(&self) -> RawFd { + (**self).as_raw_fd() + } +} + #[stable(feature = "asrawfd_ptrs", since = "1.63.0")] impl<T: AsRawFd> AsRawFd for Box<T> { #[inline] |
