]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/os/windows/io/handle.rs
Add `IsTerminal` trait to determine if a descriptor or handle is a terminal
[rust.git] / library / std / src / os / windows / io / handle.rs
index 16cc8fa2783eea6c13492710ccebfbe977e1b9ff..1dfecc57338a7bbab9e5533a638dddc489a5d963 100644 (file)
@@ -384,6 +384,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!(BorrowedHandle<'_>, OwnedHandle);
+
 /// A trait to borrow the handle from an underlying object.
 #[stable(feature = "io_safety", since = "1.63.0")]
 pub trait AsHandle {