From 3b26d6b7a5efea4c357afc2d5382f009412407f6 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 23 Aug 2023 10:12:24 -0500 Subject: [PATCH] feat(wincon): Allow querying is_terminal --- Cargo.toml | 2 +- crates/anstyle-wincon/src/console.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a1cde3f8..e0e9b920 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ resolver = "2" [workspace.package] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.64.0" # MSRV +rust-version = "1.70.0" # MSRV include = [ "build.rs", "src/**/*", diff --git a/crates/anstyle-wincon/src/console.rs b/crates/anstyle-wincon/src/console.rs index 33584283..f89de843 100644 --- a/crates/anstyle-wincon/src/console.rs +++ b/crates/anstyle-wincon/src/console.rs @@ -87,11 +87,24 @@ where Ok(()) } + fn as_stream(&self) -> &S { + self.stream.as_ref().unwrap() + } + fn as_stream_mut(&mut self) -> &mut S { self.stream.as_mut().unwrap() } } +impl Console +where + S: crate::WinconStream + std::io::Write + std::io::IsTerminal, +{ + pub fn is_terminal(&self) -> bool { + std::io::IsTerminal::is_terminal(self.as_stream()) + } +} + impl Drop for Console where S: crate::WinconStream + std::io::Write,