]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/os/fd/owned.rs
Rollup merge of #93400 - ChayimFriedman2:dont-suggest-using-const-with-bounds-unused...
[rust.git] / library / std / src / os / fd / owned.rs
index b53c3e79b0fe6e7a9046a434ef3623ec313baa31..d72f9a2ff9c8f8a9fa53238730a1aefaebffb64b 100644 (file)
@@ -8,7 +8,7 @@
 use crate::fs;
 use crate::marker::PhantomData;
 use crate::mem::forget;
-#[cfg(not(target_os = "wasi"))]
+#[cfg(not(any(target_os = "wasi", target_env = "sgx")))]
 use crate::sys::cvt;
 use crate::sys_common::{AsInner, FromInner, IntoInner};
 
@@ -200,6 +200,22 @@ pub trait AsFd {
     fn as_fd(&self) -> BorrowedFd<'_>;
 }
 
+#[unstable(feature = "io_safety", issue = "87074")]
+impl<T: AsFd> AsFd for &T {
+    #[inline]
+    fn as_fd(&self) -> BorrowedFd<'_> {
+        T::as_fd(self)
+    }
+}
+
+#[unstable(feature = "io_safety", issue = "87074")]
+impl<T: AsFd> AsFd for &mut T {
+    #[inline]
+    fn as_fd(&self) -> BorrowedFd<'_> {
+        T::as_fd(self)
+    }
+}
+
 #[unstable(feature = "io_safety", issue = "87074")]
 impl AsFd for BorrowedFd<'_> {
     #[inline]