mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
kmc-solid: Implement AsFd
for {Arc,Rc,Box}<impl AsFd>
This commit is contained in:
parent
cf9c4a32f3
commit
0dd3b25e2d
@ -271,6 +271,39 @@ macro_rules! impl_owned_fd_traits {
|
||||
}
|
||||
impl_owned_fd_traits! { TcpStream TcpListener UdpSocket }
|
||||
|
||||
/// This impl allows implementing traits that require `AsFd` on Arc.
|
||||
/// ```
|
||||
/// # #[cfg(target_os = "solid_asp3")] mod group_cfg {
|
||||
/// # use std::os::solid::io::AsFd;
|
||||
/// use std::net::UdpSocket;
|
||||
/// use std::sync::Arc;
|
||||
///
|
||||
/// trait MyTrait: AsFd {}
|
||||
/// impl MyTrait for Arc<UdpSocket> {}
|
||||
/// impl MyTrait for Box<UdpSocket> {}
|
||||
/// # }
|
||||
/// ```
|
||||
impl<T: AsFd> AsFd for crate::sync::Arc<T> {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
(**self).as_fd()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AsFd> AsFd for crate::rc::Rc<T> {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
(**self).as_fd()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: AsFd> AsFd for Box<T> {
|
||||
#[inline]
|
||||
fn as_fd(&self) -> BorrowedFd<'_> {
|
||||
(**self).as_fd()
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait to extract the raw SOLID Sockets file descriptor from an underlying
|
||||
/// object.
|
||||
pub trait AsRawFd {
|
||||
|
Loading…
Reference in New Issue
Block a user