]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/os/fd/owned.rs
Add `IsTerminal` trait to determine if a descriptor or handle is a terminal
[rust.git] / library / std / src / os / fd / owned.rs
index 9d758320cfcc68f20cd32331ae53cb08342f7588..c16518577f7c466794127c9db77be3136e3d4c46 100644 (file)
@@ -193,6 +193,23 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     }
 }
 
+macro_rules! impl_is_terminal {
+    ($($t:ty),*$(,)?) => {$(
+        #[unstable(feature = "sealed", issue = "none")]
+        impl crate::sealed::Sealed for $t {}
+
+        #[unstable(feature = "is_terminal", issue = "98070")]
+        impl crate::io::IsTerminal for $t {
+            #[inline]
+            fn is_terminal(&self) -> bool {
+                crate::sys::io::is_terminal(self)
+            }
+        }
+    )*}
+}
+
+impl_is_terminal!(BorrowedFd<'_>, OwnedFd);
+
 /// A trait to borrow the file descriptor from an underlying object.
 ///
 /// This is only available on unix platforms and must be imported in order to