File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,39 @@ macro_rules! impl_owned_fd_traits {
271
271
}
272
272
impl_owned_fd_traits ! { TcpStream TcpListener UdpSocket }
273
273
274
+ /// This impl allows implementing traits that require `AsFd` on Arc.
275
+ /// ```
276
+ /// # #[cfg(target_os = "solid_asp3")] mod group_cfg {
277
+ /// # use std::os::solid::io::AsFd;
278
+ /// use std::net::UdpSocket;
279
+ /// use std::sync::Arc;
280
+ ///
281
+ /// trait MyTrait: AsFd {}
282
+ /// impl MyTrait for Arc<UdpSocket> {}
283
+ /// impl MyTrait for Box<UdpSocket> {}
284
+ /// # }
285
+ /// ```
286
+ impl < T : AsFd > AsFd for crate :: sync:: Arc < T > {
287
+ #[ inline]
288
+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
289
+ ( * * self ) . as_fd ( )
290
+ }
291
+ }
292
+
293
+ impl < T : AsFd > AsFd for crate :: rc:: Rc < T > {
294
+ #[ inline]
295
+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
296
+ ( * * self ) . as_fd ( )
297
+ }
298
+ }
299
+
300
+ impl < T : AsFd > AsFd for Box < T > {
301
+ #[ inline]
302
+ fn as_fd ( & self ) -> BorrowedFd < ' _ > {
303
+ ( * * self ) . as_fd ( )
304
+ }
305
+ }
306
+
274
307
/// A trait to extract the raw SOLID Sockets file descriptor from an underlying
275
308
/// object.
276
309
pub trait AsRawFd {
You can’t perform that action at this time.
0 commit comments