Skip to content

Commit

Permalink
Rollup merge of rust-lang#107317 - ids1024:asfd-rc, r=dtolnay
Browse files Browse the repository at this point in the history
Implement `AsFd` and `AsRawFd` for `Rc`

Fixes rust-lang#105931.
  • Loading branch information
compiler-errors authored Feb 9, 2023
2 parents ef934d9 + c13669e commit 4212d25
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions library/std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 4212d25

Please sign in to comment.