From f4acdc210637397b94b2928ba8f38427fc79596f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 9 Aug 2023 10:41:13 -0500 Subject: [PATCH 1/2] refactor(wincon): Move Drop to more relevant location --- crates/anstyle-wincon/src/console.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/anstyle-wincon/src/console.rs b/crates/anstyle-wincon/src/console.rs index 6b89740c..eb7f590e 100644 --- a/crates/anstyle-wincon/src/console.rs +++ b/crates/anstyle-wincon/src/console.rs @@ -106,6 +106,18 @@ where } } +impl Drop for Console +where + S: crate::WinconStream + std::io::Write, +{ + fn drop(&mut self) { + // Otherwise `Console::lock` took it + if self.stream.is_some() { + let _ = self.reset(); + } + } +} + impl Console where S: crate::WinconStream + std::io::Write, @@ -142,15 +154,3 @@ where self.lock() } } - -impl Drop for Console -where - S: crate::WinconStream + std::io::Write, -{ - fn drop(&mut self) { - // Otherwise `Console::lock` took it - if self.stream.is_some() { - let _ = self.reset(); - } - } -} From 912eaf429c7919010ba86fb34a967b3f57be05ad Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 9 Aug 2023 15:47:00 -0500 Subject: [PATCH 2/2] style(anstream): Clarify wincon code --- crates/anstream/src/auto.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/anstream/src/auto.rs b/crates/anstream/src/auto.rs index b252c05c..a4f71f30 100644 --- a/crates/anstream/src/auto.rs +++ b/crates/anstream/src/auto.rs @@ -130,7 +130,7 @@ where StreamInner::PassThrough(w) => w.is_terminal(), StreamInner::Strip(w) => w.is_terminal(), #[cfg(all(windows, feature = "wincon"))] - StreamInner::Wincon(w) => true, + StreamInner::Wincon(_) => true, // its only ever a terminal } } }